Exit Exam Model For Software Engineering

Haramaya University

College of Computing and Informatics

Department of Computer Science

Model Exam Round-II

Software Engineering

  1. Assume you are requested to model the library management system of the classes, and there is the relationship that a library contains students and books. From these classes which of the following relationship is not true?
  2. The relationship between library and books is aggregation
  3. The relationship between library and student is aggregation
  4. The relationship between library and books is composition.
  5. The relationship between books and student is association
  6.  Consider a file system with a graphical user interface, such as Macintosh’s Finder, Microsoft’s Windows Explorer, or Linux’s KDE. The following objects were identified from a use case describing how to copy a file from a floppy disk to a hard disk: File, Icon, TrashCan, Folder, Disk, and Pointer. Based on the above scenario (description) which of the following is true?
  7. File, Folder, and pointer are boundary objects
  8. File, Folder, Disk, and TrashCan are control Objects
  9. Icon, TrashCan, and pointer are entity objects
  10. File, Folder, and Disk are Entity objects
  11. Which one of the following statements is incorrect?
  12. High cohesion subsystem contains related objects performing similar tasks
  13. In weakly coupled, changes to one subsystem likely to affect the other
  14. Low cohesion subsystem contains a number of unrelated objects
  15. In strongly coupled, changes to one subsystem likely to affect the other
  16. Suppose you are requested to develop a web-based system with the following functionalities; the user should sign up for the system, the user should log into the system and can send or accept friend request. Firstly, you convert this system into separate modules that is; Module1: Sign up and log in, Module 2: Send Friend request, and Module 3: Accept friend request. When you start your activities, you started with Module 1(signup and login). This module undergoes the phases of requirements gathering and analysis, design, implementation, deployment, and maintenance. When this module is ready, you deliver this module to the customer. After that, you add module2 that sends the friend request. Similarly, this module undergoes the phases of requirements gathering and analysis, design, implementation, deployment, and maintenance. When this module is ready, you deliver this module to the customer. Finally, in similar way the last module added. Based on the above activities and scenarios, what type of software process model (approach) you used?
  17. Agile model
  18. Waterfall model
  19. Incremental model
  20. Iterative model
  21. In which type of project used in re-design and/or re-implementation of an existing system using newer technology?
  22. Green field    
  23. Re-engineering
  24. Interface engineering project
  25. None
  26. At the time of doing a projects unanticipated risk may occur. Once risks have been identified and prioritized, mitigation strategies need to be designed for the critical risks. Mitigation strategies can include lowering the likelihood of the risk or decreasing its potential impact. Assume the following risk called “selected middleware too slow to meet performance requirement for data logging” has been identified. Then from the following alternatives which one is the mitigation strategy for the mentioned risk?
  27. Plan for a performance evaluation prototype
  28. Develop alternate interface
  29. Assign key developers to this task.
  30. Increase the priority of this task with respect to other implementation tasks.

Web Programming

  • What is the correct interpretation of the following CSS script snippet?

p.class1 {

            text-align: center;

}

  1. All paragraphs get centered
  2. All paragraphs with the class of class1 get centered
  3. All elements inside the paragraphs get centered
  4. All elements with the class of class1 get centered
  5. Choose the correct interpretation of the following CSS script snippet.

            <style>

                        p {color: red;}

                        #p2{color: inherit;}

            </style>

            <p>Hello paragraph 1</p>

            <p id=”p2″>Hello paragraph 2</p>

            <p>Hello paragraph 3</p>

  1.  All paragraphs are red colored.
  2. All paragraphs are black colored
  3. Except paragraph 2 all are red cod colored.
  4. None of the above
  5. Which of the following JavaScript display method is used to change the content of HTML elements.
  6. innerHTML
  7. document.write()
  8. console.log ()
  9. window.alert()
  10. Which one is true regarding variable declaration in JavaScript?
  11. Const declares read only global variables.
  12. Let declares block scoped, local variables.
  13. Var declares local scope, read-only variables.
  14.  All of the above
  15. Choose correct output of the following object looping using for … in.

            const obj = {name:’XYZ’};

            for (x in obj)

                        console.log(obj);

  1. No output
  2. XYZ
  3. name
  4. All of the above
  5. Which one of the following will attach one file to another in PHP?
  6. include(“file2.php”)
  7. import(“file2.php”)
  8. attach(“file2.php”)
  9. None of the above.
  10. Which one is true about session and cookies?
    1. Cookies can be disabled on client machine but sessions are not.
    1. Session is stored on web server but cookies are stored on client.
    1. Cookies stay on the client until their expiry time.
    1. All of the above.
  11. One of the following methods is used to send binary input to server in HTML forms.
  12. POST
  13. GET
  14. HTTP
  15. None of the above
  16. Which way of setting a new cookie is correct, with key of ‘Location’ and value of ‘Harar’?
  17. setcookie(“Harar”, “Location”)
  18. setcookie(“Location”, “Harar”)
  19. setcookie(“Location”, time()+60, “Harar”)
  20. setcookie(time()+60, “Location”, “Harar”)

Database Systems

  1. What is information about data called?
    1. Hyper data
    1. Tera data
    1. Meta data
    1. Relations
  2. What does an RDBMS consist of?
    1. Collection of Records
    1. Collection of Keys
    1. Collection of Tables
    1. Collection of Fields
  3. The ability to query data, as well as insert, delete, and alter tuples, is offered by ____________
    1. TCL (Transaction Control Language)
    1. DCL (Data Control Language)
    1. DDL (Data Definition Language)
    1. DML (Data Manipulation Language)
  4. What happens if a piece of data is stored in two places in the database?
    1. Storage space is wasted & changing the data in one spot will cause data inconsistency
    1. In can be more easily accessed
    1. Changing the data in one spot will cause data inconsistency
    1. Storage space is wasted
  5. In E-R diagram derived attribute are represented by
    1. Ellipse
    1. Dashed ellipse
    1. Rectangle
    1. Triangle
  6. Which of the following is true concerning the following statement: class Manager extends Employee_________
    1. Manager is a concrete class and a subclass
    1. Manager is a concrete class and a superclass
    1. Manager is an abstract class and a subclass
    1. Manager is an abstract class and a superclass
  7. Various concurrency-control schemes are used to ensure
    1. Serializability
    1. Deadlock prevention
    1. Timeouts
    1. Locking states
  8. The most common concurrency-control schemes include locking protocols and
    1. Timestamp-ordering schemes
    1. Validation techniques
    1. Multiversion schemes
    1. All of the Above
  9. An integral part of database that can restore the database to the consistent state of before failure is called
    1. Recovery scheme
    1. Backup scheme
    1. Restoring scheme
    1. Transaction scheme
  10. Which of the following is a basic form of grant statement?
    1.  GRANT ‘privilege list’

          ON ‘relation name or view name’

             TO ‘user/role list’;

  • GRANT ‘privilege list’

          ON ‘user/role list’

             TO ‘relation name or view name’;

  • GRANT ‘privilege list’

           TO ‘user/role list’;

  • GRANT ‘privilege list’

         ON ‘relation name or view name’

             ON ‘user/role list’;

  • An autonomous homogenous environment is which of the following?
    • The same DBMS is at each node and each DBMS works independently.
    • The same DBMS is at each node and a central DBMS coordinates database access.
    • A different DBMS is at each node and each DBMS works independently.
    • A different DBMS is at each node and a central DBMS coordinates database access.
  • A heterogeneous distributed database is which of the following?
    • The same DBMS is used at each location and data are not distributed across all nodes.
    • The same DBMS is used at each location and data are distributed across all nodes.
    • A different DBMS is used at each location and data are not distributed across all nodes.
    • A different DBMS is used at each location and data are distributed across all nodes.

Computer Programming

  • In a function declaration, it is possible to use default argument, in which default value is a value to be used if no one is supplied from the function caller. Accordingly, which one of the following is the correct way of setting default values for a function named as myFunction which has three parameters named as x, y and z of integer data type?
  • long myFunction (int x = 50, int y, int z);
  • long myFunction (int x , int y, int z=150);
  • long myFunction (int x = 50 , int  y = 100, int z);
  • All of the above
  • A structure definition is a user-defined variable type which is a grouping of one or more variables. Which one of the following is not correct about structure?
  • Once the type has been defined through the C++ ‘struct’ keyword, you can create variables from it just like you would any other type.
  • After creating a structure variable you must create a structure definition.
  • The structure definition is a listing of all member variables with their types and names.
  • Defining a structure is giving the compiler a blueprint for creating your type.
  • None of the Above
  • Which one of the following is an operator specifically used to access structure members through a pointer?
  • *.
  • – >
  • < –
  • .(dot)
  • All of the Above
  • Assume that enumeration called transport is defined as: enum transport { car, truck, airplane = 10, train, boat}; What will be the output for the following fragment of code?

transport t= train;

cout<<t;

  1. train
  2. 3
  3. 11
  4. transport
  5. All of the Above 
#include <iostream>int main ( ){int *ptr1, *ptr2, *ptr3, i = 0, j = 1, k = 2;ptr1 = &i;i = *ptr1 ? 3 : 4;ptr2 = &j;j = *ptr2 + *ptr1;ptr3 = &k;k = *ptr3 + *ptr2;std::cout << *ptr1 << ‘- ‘ << *ptr2 << ‘ -‘ << *ptr3 << ‘\n’;return 0; }  

 What is the output of the following program?

  1. 2-5-7
  2. 0-1-5
  3. 4-5-7
  4. 0-2-5
  5. Error Message
  6.  Consider two-dimensional integer array a [ROWS] [COLS]. Since its elements are stored sequentially in computer memory, which one of the following is correct way of computing memory address for a[i] [j]?
  7. a + (i × COLS × sizeof(int)) + (j × sizeof(int))
  8. a + (i × ROWS × sizeof(int)) + (j × sizeof(int))
  9. a + (i × sizeof(int)) + (j × COLS × sizeof(int))
  10. a + (i ×  sizeof(int)) + (j × sizeof(int))
  11. a + (i × COLS × sizeof(int)) + (j × ROWS ×sizeof(int))

Object Oriented Programming

  • What is encapsulation in OOP?
  • It is a way of combining various data members and member functions that operate on those data members into a single unit.
  • It is a way of combining various data members and member functions into a single unit which can operate on any data
  • It is a way of combining various data members into a single unit
  • It is a way of combining various member functions into a single unit
  • In which access should a constructor be defined, so that object of the class can be created in any function?
    • Any access specifier will work
    • Private
    • Public
    • Protected
  • Which of the following OOP concept binds the code and data together and keeps them secure from the outside world?
  • Polymorphism
  • Inheritance
  • Abstraction
  • Encapsulation
  • Which of the following is not an OOPS concept?
    • Encapsulation
    • Polymorphism
    • Exception
    • Abstraction
  • Which two features of object-oriented programming are the same?
    • Abstraction and Polymorphism features are the same
    • Inheritance and Encapsulation features are the same
    • Encapsulation and Polymorphism features are the same
    • Encapsulation and Abstraction
  • Runtime polymorphism feature in java is
    • Method overriding
    • Method overloading
    • Operator overloading
    • Constructor overloading

Design and Analysis of Algorithms

  • Consider the graph shown below. Which of the following are the edges in the MST of the given graph?
Description: E:\faiz backup\HU\Questions\2023\graph1.JPG
  1. (a-c)(c-d)(d-b)(d-b)
  2. (c-a)(a-d)(d-b)(d-e)
  3. (a-d)(d-c)(d-b)(d-e)
  4. (c-a)(a-d)(d-c)(d-b)(d-e)
  5. Which of the following is true?
  6. Prim’s algorithm initializes with a vertex.
  7. Prim’s algorithm initializes with an edge.
  8. Prim’s algorithm initializes with a vertex which has smallest edge.
  9. Prim’s algorithm initializes with a forest.
  10. Worst case is the worst-case time complexity of Prim’s algorithm if adjacency matrix is used?
  11. O(log V)
  12. O(V2)
  13. O(E2)
  14. O(V log E)
Description: E:\faiz backup\HU\Questions\2023\graph2.JPG

Consider the graph shown below. Which of the following edges form the MST of the given graph using Prim’s algorithm, starting from vertex 4.

  1. (4-3)(5-3)(2-3)(1-2)
  2. (4-3)(3-5)(5-1)(1-2)
  3. (4-3)(3-5)(5-2)(1-5)
  4. (4-3)(3-2)(2-1)(1-5)
  5. A person wants to visit some places. He starts from a vertex and then wants to visit every vertex till it finishes from one vertex, backtracks and then explore other vertex from same vertex. What algorithm he should use?
  6. Depth First Search
  7. Breadth First Search
  8. Trim’s algorithm
  9. Kruskal’s Algorithm
Description: E:\faiz backup\HU\Questions\2023\graph3.JPG

Consider the following graph. Using Kruskal’s algorithm, which edge will be selected first?

  1. GF
  2. DE
  3. BE
  4. BG

Data Communication and Computer Networking

  • Which OSI layer is responsible for order preservation of sequence of packets between source and destination if there is jitter in the arrival time?
  • Presentation Layer
  • Data link Layer
  • Transport Layer
  • Network Layer
  • According to the IEEE 802 standard, what is the right ordering of the layers:
  • MAC Layer, IP Layer, TCP Layer, LLC Layer, Application Layer
  • MAC Layer, LLC Layer, IP Layer, TCP Layer, Application Layer
  • LLC Layer, MAC Layer, IP Layer, TCP Layer, Application Layer
  • LLC Layer, MAC Layer, TCP Layer, IP Layer, Application Layer
  • MAC Layer, LLC Layer, TCP Layer, IP Layer, Application Layer
  • A service provider has given you the class B network range of 172.16.0.0 and try to break this network into as many subnets as possible.  Now a company needs to break this network to get at least 300 clients per subnet. If you break this network based on the above requirements given which one is true about this scenario?
  • The new subnet mask & broadcast address of the 3rd subnet is 255.255.254.0 and 172.16.1.255 respectively.
  • The new subnet mask & broadcast address of the 1st subnet is 255.255.224.0 and 172.16.5.255 respectively.
  • The new subnet mask & broadcast address of the 3rd subnet is 255.255.224.0 and 172.16.3.255 respectively.
  • The new subnet mask & broadcast address of the 2nd subnet is 255.255.254.0 and 172.16.3.255 respectively.
  • A service provider has given you the class C network range of 209.50.1.0. Now a company needs to break this network into 20 separate subnets. Now if you break this network what is the new subnet mask for your subnets?
  • 255.255.255.0                         
  • C. 255.255.224.0
  • 255.255.248.0                         
  • D. 255.255.255.248
  • You want to create a crossover cable to connect two systems directly together. Which wires would you have to switch at one end of the cable?
  • Wires 1 and 2 with wires 3 and 6
  • Wires 1 and 2 with wires 6 and 8
  • Wires 1 and 2 with wires 3 and 4
  • Wires 2 and 3 with wires 3 and 6
  • What does a network interface card add to a computers functionality?
  • It provides faster communication between the CPU and the hard disk.
  • It provides the capability to communicate across a phone line to another computer.
  • It provides the capability to communicate with other commuters across a network medium.
  • It provides the capability to save more information on a diskette than normal.

Computer Security

  • Mr.Akubazgi is teaching an introductory computer security course and is trying to explain the terminology to students. What is the term for a person who uses tools to hack without understanding the underlying technology?
    • A script kiddy
    • A gray hat hacker
    • A novice
    • A white hat hacker
  • Which one of the following is an attack on availability?
    • Spoofing
    • Masquerading
    • Delay
    • Snooping
  • Which one of the following algorithms is not applicable for digital signature?
    • RSA
    • Diffie-Hellman
    • Elliptic Curve
    • DSS
  • Which one is a violation against confidentiality?
    • Chala copies Abebe’s homework.
    • Bekele crashes Tolosa’s system.
    • Bekele changes the amount of Abebech’s check from $100 to $1000.
    • Ayele registers the domain name “HaramayaUniversity.com” and refuses to let the publishing house buy or use that domain name.
  • Mr.Tadesse is explaining various malware types to new technical support personnel. He is explaining to them the various types of malwares so that they can recognized them. What type of malware is a key logger?
    • Virus
    • Buffer overflow
    • Trojan horse
    • Spyware
  • What is the rule in access control?
    • Grant the most access you can securely give
    • Grant the least access job requirements allow
    • Grant standard access for all users
    • Strictly limited access for most users

Network and System Administration

  • System administrator must cater to all needs, and ensure the stability of system for the users.  Which of the following is not a common user management task in an operating system?
  • Creating new user accounts
  • Modifying existing user accounts
  • Deleting user accounts
  • Installing software for users
  • What is the purpose of creating groups in an operating system?
  • To organize users with similar permissions or roles
  • To limit access to specific files or directories
  • To increase system performance
  • None of the above
  • In a window domain, directory resides on computer that are configured as domain controller. Which one of the following is a key function of a domain controller in a Windows network?
  • To manage user accounts and authentication
  • To provide internet connectivity to network devices
  • To monitor network performance and troubleshoot issues
  • To manage hardware resources such as printers and scanners
  • Which of the following is a key feature of Active Directory Sites and Services in a Windows network?
  • It allows for centralized management of network devices
  • It provides real-time monitoring of network traffic
  • It enables replication of directory data across multiple sites
  • It allows for remote access to network resources from any location
  • What is the main difference between a client-server network and a peer-to-peer network on network operating system architecture?
  • In a client-server network, resources are centralized and managed by a server, while in a peer-to-peer network, resources are shared among all connected devices.
  • In a client-server network, all devices have equal authority and can access and modify any resource, while in a peer-to-peer network, each device has its own resources that are not accessible by other devices.
  • In a client-server network, devices communicate directly with each other, while in a peer-to-peer network, all communication goes through a central server.
  • In a client-server network, all devices are connected through a single cable or wire, while in a peer-to-peer network, devices can be connected wirelessly or through multiple cables.
  • System administration is not only just installing system it about designing efficient community of computers. What are the biggest challenges faced by system administrators when it comes to security?
  • Keeping up with constantly evolving threats
  • Ensuring all employees follow security protocols
  • Implementing complex security measures
  • Balancing security with accessibility

Artificial Intelligence

  • As a simple knowledge-based agent, which component enables it to operate based on stored information to make decisions?
    • Make-percept-sentence that which constructs a sentence asserting that the agent perceived the given percept at the given time.
    • Make-action-query that constructs a sentence that asks what action should be done at the current time.
    • Make-action-sentence that constructs a sentence asserting that the chosen action was executed.
    • All of the Above
  • In AI, if agent knows exactly about the state, the problem type is ____________________.
    • Single-state problem
    • Conformant problem
    • Exploration problem
    • Contingency problem
  • ___________________________ is the most effective way to handle partial observability of the agent to keep track of the world.
    • Simple reflex agents
    • Goal-based agents
    • Model-based reflex agents
    • Utility-based agents
  • Which one of the following is correct concept of a stochastic hill-climbing search, which has to be applied to an evolutionary algorithm?
    • It looks ahead beyond the immediate neighbors of the current state.
    • It generates new states by mutation and crossover, which combines pairs of states.
    • It continues even when it reaches a “peak” where no neighbor has a higher value.
    • It uses positive of a heuristic cost function as the objective function
  • Which one of the following is wrong characteristics of iterative deepening search strategy?
  • Complete
  • Time complexity is O(bd)
  • Optimal
  • None of the Above
  • Web crawling is type of search for a relevant document from given seed documents in which focused crawlers helps to improvise search efficiency. In this context, this type of agent is _______________________________________.
    • Problem-solving agent
    • Simple reflex agent
    • Intelligent goal-based agent
    • Model based agent

Operating System

  • Consider the given below and calculate both miss and hit ration of memory management page replacement in five frame using optimal page replacement algorithm. Given: 3  8  1  3  5  4  6  1  8  9  4  2  3  1  6  8  9  0  1  2  3 
  •  11:21 hit ration and 10:21 miss ratio       
  •  5:21 hit ratio and 16:21 miss ratio
  •  13:21 miss ratio and 8:21 hit ratio      
  • 4:21 hit ratio and 17:21 miss ratio
    • From the following which one is incorrect regarding to whole CPU scheduling     algorithm
  • All Non Preemptive CPU scheduling have the same waiting time and response time.
  • First come first serve CPU scheduling algorithm never care about execution time when we  design the gantt chart.
  • Preemptive shortest job first CPU algorithm waiting time are smaller than waiting time of first come first serve CPU scheduling
  • Both preemptive and non preeptive priority CPU scheduling are based on burst time.
    • Consider the following processes, with the CPU burst times and arrival times given in mill seconds and If we have five processes (p0, p1, p2, p3, p4 and Execution time, 3, 1, 6, 2, 4, arrival times 0, 2, 7, 3, 4, with priority, 2, 4, 3, 5, 2, if smallest integer represent highest priority value, which order of processes are correct using CPU preemption priority scheduling?
  •  P0P1P3P4P2
  •  P0P2P3P4P1
  •  P0P1P3P2P4
  • P0P1P4P2P3
    • From the following alternatives which one is correct about process and thread?
  • Process can communicate without IPC as thread.
  • Threads have individual existences.
  • Thread can communicate with each other using inter-process communication only.
  • One process has more than one threads
    • Among the following operating system which one accept ostrich algorithm for deadlock detection techniques?
    • Mac Operating System
    • Unix Operating System
    • Apple I Operating System
    • DOS Operating System
      • From the following which one is used to Abort all deadlocked processes, or Abort one process at a time until the deadlocked cycle disappears?
  • Deadlock Recovery
  • Deadlock Detection and Prevention
  • Process Termination
  • Resource Preemption
  • Deadlock Avoidance

Computer Organization and Architecture

  • Which of the architecture is power efficient?
  • RISC                    
  • ISA                       
  • IANA                               
  • CISC
    • Which of the following is the subcategories of computer architecture?
  • Microarchitecture                                  
  • Instruction set architecture      
  • Systems design                          
  • All of the mentioned
    • In CISC architecture most of the complex instructions are stored in _____
  • CMOS                 
  • Register
  • Transistors                                 
  • Diodes
    • The processing required for a single instruction is called ___.
  • Fetch cycle                      
  • Execution cycle
  • Instruction cycle
  • Branch cycle
    • The fetched instruction is stored in the CPU register known as.
  • IRC Instruction register                        
  • PC Program counter
  • MARC Memory address Register      
  • MDRC memory Data Register
    • What is a multiplexer?
  • It is a type of decoder which decodes several inputs and gives one outputc
  • A multiplexer is a device which converts many signals into one
  • It takes one input and results into many output
  • It is a type of encoder which decodes several inputs and gives one output

Automata and Complexity Theory

  • Automata theory, computability theory, and complex theory are all topics covered in the study of the theory of computation. Which of the following represents the main objective of complexity theory?
  • To classify problems as easy ones and hard ones
  • To classify problems by those that are solvable and those that are not solvable.
  • To deal with definitions and properties of mathematical models of computation.
  • All
    • What is the language and grammar accepted by pushdown automata?
  • Regular language and type-3 grammar
  • Context-free language and type-2 grammar
  • Context-free language and type-3 grammar
  • Context-sensitive language and type-1 grammar
    • Which of the following is the mechanism for simplifying the context-free grammar?
  • Eliminating useless symbols
  • Elimination -productions
  • Eliminating unit productions
  • All
    • Which one of the following languages over the alphabet {0, 1} is described by the regular expression: (0+1)*0(0+1)*0(0+1)*?
    • The set of all strings containing the substring 00
    • The set of all strings containing at most two 0’s
    • The set of all strings containing at least two 0’s
    • The set of all strings that begin and end with either 0 and 1
      • In a computational complexity theory, a problem with decision making is said to be NP-complete when it is both in NP and NP-hard. What does NP mean?
  • Non polynomial time                                 
  • Non-deterministic polynomial time
  • Non-deterministic probabilistic
  • Non-probabilistic time
    • The grammar production: AaB refers to which of the following forms?
  • Greibach Normal Form                  
  • Chomsky Normal Form
  • Backus Naur Form                          
  • None

Compiler Design

  • Which phase of the compiler checks the grammar of the programming?
  • Code optimization
  • Semantic analysis
  • Code generation
  • Syntax Analysis
    • Which compiler runs on one machine and generates code for multiple machines?
  • Multipass compiler
  • Cross compiler
  • Optimizing compiler
  • Onepass compiler
    • Consider a program P that consists of two source modules M1 and M2 contained in two different files. If M1 contains a reference to a function defined in M2the reference will be resolved at__________________.
  • Edit time                                                       
  • Compile time
  • Link time
  • Load time
    • Which one of the following grammars is free from left recursion?
  • Which one of the following doesn’t describe syntax-directed definitions?
  • Hide many implementation details such as order of evaluation of semantic actions
  • Indicate the order of evaluation of semantic actions associated a production rule
  • Give high-level specifications for translations
  • All
    • Which of the following checks is a typical example of static checking?
  • Flow of control checks
  • Uniqueness checks
  • Type checks
  • All

Data Structures and Algorithms

  • For the following pieces of code what would be the big-O complexity in terms of the size of the data n (consider assignment statements only). Remember that to prove the complexity you must find values for the constants c and N that satisfy the formal mathematical definition.

for (p = 0, sum = 0; p < n; p++)

  for (q = 1; q < n; q = q*2)

    sum += c[p][q];

  1. O(nlog n)
  2. O(n3)
  3. O(log n)
  4. O(n)Looking at the following program, what searching and sorting algorithm is been used respectively?

#include<iostream.h>

int main()

{

int i,j,before,after,min,loc,tmp;

int n=5;

int arr[5];

for(i=0;i<n;i++)

{

cout<<“Enter Elements of the array at “<<i<<“\t”;

cin>>arr[i];

}

cout<<endl;

cout<<“Array Element Before Sorting”;

for(before=0;before<n;before++)

{

cout<<arr[before]<<“\t”;

}

for(i=0;i<n;i++)

{

min=arr[i];

loc=i;

for(j=i+1;j<n;j++)

{

if(arr[j]>min)

{

min=arr[j];

loc=j;

}

}

if(loc!=i)

{

tmp=arr[i];

arr[i]=arr[loc];

arr[loc]=tmp;

}

}

cout<<“Array Element After Sorting”;

for(after=0;after<n;after++)

{

cout<<arr[after]<<“\t”;

}

return 0;

}

  1. Linear search and merge sort algorithm
  2. Linear search and bubble sort algorithm
  3. Binary search and selection sort algorithm
  4. Binary search and insertion sort algorithm Which element/s would be left in the stack after performing the series of push and pop operations?

Push (A),     Push (B),     Push (C),     Pop(),     Push (D),     Pop()

  1. BC
  2. AB
  3. BA
  4. D
    1. Which element/s would be left in the queue after performing the series of Enqueue and Dequeue operations?

Enqueue(A),     Enqueue(B),     Dequeue(),     Enqueue(C),     Dequeue(),     Enqueue(D)

  1. AB
  2. BC
  3. C
  4. CD
    1. Of the following statements, which one is not correct about singly linked list?
  5. It is a collection of elements in sequential order
  6. The list can be implemented using static or dynamic memory allocation
  7. The list has head and tail pointers to traverse forward and backward through the list
  8. It possible to store elements of the list in an array
    1. Which one of the following is not correct about tree data structure?
  9. It is a set of nodes and edges that connect pairs of nodes.
  10. It is an abstract model of a hierarchical structure.
  11. The root is the top node that has no parent nodes.
  12. The leaves of the tree are those that have only one child nodes.
    1. In _______________ sort the original array is first divided into two sub arrays, the first of which contains only elements that are less than or equal to a chosen element, called the bound or pivot.  The second sub array contains elements that are greater than or equal to the bound. If each of these sub arrays is sorted separately they can be combined into a final sorted array.
  13. Merge
  14. Quick
  15. Shell
  16. Selection

Leave a Comment