Algorithms and Data Structures
Covers algorithm complexity analysis, sorting and searching algorithms, arrays, linked lists, and fundamental data structure operations
Questions
Benefits of the observer pattern include:
- Creates an abstract coupling between the subject and the observer
- Allows the subject and observer to belong to different layers of abstraction
- Supports notifications in the form of broadcasts
- All of the above
Key Concept for applying the Strategy Pattern:
- At any given time only one algorithm is instantiated and active
- The Strategy pattern encapsulates related classes that have different functionalities
- The name of the message to the strategy object and the context object must be the same
- None of the above
The complexity of Binary search algorithm is
- O(n)
- O(log n)
- O(n2)
- O(n log n)
The indirect change of the values of a variable in one module by another module is called
- internal change
- inter-module change
- side effect
- side-module update
Which of the following data structure is not linear data structure?
- Arrays
- Linked lists
- Both of above
- None of above
Which of the following data structure is linear data structure?
- Trees
- Graphs
- Arrays
- None of above
The operation of processing each element in the list is known as
- Sorting
- Merging
- Inserting
- Traversal
Finding the location of the element with a given value is:
- Traversal
- Search
- Sort
- None of above
Arrays are best data structures
- for relatively permanent collections of data
- for the size of the structure and the data in the structure are constantly changing
- for both of above situation
- for none of above situation
Linked lists are best suited
- for relatively permanent collections of data
- for the size of the structure and the data in the structure are constantly changing
- for both of above situation
- for none of above situation
Each array declaration need not give, implicitly or explicitly, the information about
- the name of array
- the data type of array
- the first data from the set to be stored
- the index set of the array
The elements of an array are stored successively in memory cells because
- by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated
- the architecture of computer memory does not allow arrays to store other than serially
- both of above
- none of above
Two main measures for the efficiency of an algorithm are
- Processor and memory
- Complexity and capacity
- Time and space
- Data and space
Which of the following case does not exist in complexity theory
- Best case
- Worst case
- Average case
- Null case
The Average case occur in linear search algorithm
- When Item is somewhere in the middle of the array
- When Item is not in the array at all
- When Item is the last element in the array
- When Item is the last element in the array or is not there at all
The complexity of the average case of an algorithm is
- Much more complicated to analyze than that of worst case
- Much more simpler to analyze than that of worst case
- Sometimes more complicated and some other times simpler than that of worst case
- None or above
The Worst case occur in linear search algorithm when
- Item is somewhere in the middle of the array
- Item is not in the array at all
- Item is the last element in the array
- Item is the last element in the array or is not there at all
The complexity of linear search algorithm is
- O(n)
- O(log n)
- O(n2)
- O(n log n)
The complexity of Bubble sort algorithm is
- O(n)
- O(log n)
- O(n2)
- O(n log n)