Computer Knowledge
Data Structures and Algorithms
1,256 Questions
Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.
Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity
Data Structures and Algorithms Questions
-
Sorted list
-
Linear list
-
Linked list
-
Unsorted list
D
Correct answer
Explanation
Linear search involves starting from the first element and sequentially checking each one until a match is found. This approach is necessary for unsorted lists since there's no order to exploit for faster searching. Sorted lists enable binary search, and linked lists are just an implementation structure.
-
Searching
-
Traversing
-
Sorting
-
Insertion
-
Deletion
B
Correct answer
Explanation
This operation in one-dimensional array is the accessing of each element of the array exactly once to do some operation.
-
FRONT=0, REAR=0
-
REAR = REAR + 1
-
FRONT = FRONT - 1
-
REAR = MAX-1
-
FRONT = -1
D
Correct answer
Explanation
This condition indicates that the queue is full of items or overflow.
-
Singly linked list
-
Circular list
-
Doubly linked list
-
Tree
-
Array
C
Correct answer
Explanation
This is the data structure in which each node points to the next node and also to the previous node.
-
Internal sorting
-
External sorting
-
Bubble sort
-
Selection sort
-
Insertion sort
A
Correct answer
Explanation
This form of sorting is applied when the entire collection of data to be sorted is small enough that the sorting can take place within main memory.
-
High=Mid-1
-
Low=Mid+1
-
High=Mid+1
-
High=Low-1
-
Low=High
A
Correct answer
Explanation
This is the correct condition as if element is lesser than a[Mid], then the required element is available in the first half of the list.
-
Loc(a[i][j]) = Base(a) + w[ (i-1) +N(j-1)]
-
Loc(a[i][j]) = Base(a) + w[N(i-1) +(j-1)]
-
Loc(a[i][j]) = Base(a) + w[M(i-1) +(j-1)]
-
Loc(a[i][j]) = Base(a) + w[ M(i-1) +N(j-1)]
-
Loc(a[i][j]) = Base(a) + w[ (i-1) +(j-1)]
B
Correct answer
Explanation
This is the correct formula because it first computes the number of elements in the rows above the specified element, N(i - 1), and adds to it the number of elements in front of the specified element in the same row, (j - 1). w is word length. Base(a) is the address of first element.
-
Linear search
-
Binary search
-
Hash search
-
Interpolation search
-
Recursive binary search
C
Correct answer
Explanation
This type of search is searching a hash table extremely fast just to find the hash value for the item that you're looking for.
-
Simple queue
-
Circular queue
-
Priority queue
-
Dequeue
-
Stack
D
Correct answer
Explanation
This is a queue in which insertion and deletion takes place at both the ends.
-
Vector-Scalar instructions
-
Vector-Vector instructions
-
Gather and Scatter instructions
-
Vector-Memory instructions
-
Masking instructions
C
Correct answer
Explanation
This type of vector instruction is an operation that fetches the non-zero elements of a sparse vector from memory.
-
text files
-
unformatted files
-
formatted data files
-
none of these
B
Correct answer
Explanation
Arrays and structures, being complex data types with specific memory layouts, are best represented by unformatted files. Unformatted files store data in binary format without any formatting conventions, preserving the exact structure and memory representation of complex data types efficiently. Formatted files use text encoding which is less efficient for such structures.
-
There are possibilities of overflow.
-
Efficient access to the items in the queue is not possible.
-
Items in the middle of the queue can be removed or deleted.
-
Items can be stored in the non-contiguous memory locations.
A
Correct answer
Explanation
When a queue is implemented using an array, the array has a fixed size. If more elements are added than the array can hold, an overflow condition occurs. This is a fundamental limitation of array-based queue implementations. Other options are incorrect - arrays do allow efficient access, don't allow middle removal without shifting, and store data contiguously.
-
Stacks
-
Arrays
-
Queues
-
Linked lists
-
int *p[10]
-
int (*p)[10]
-
int *p
-
none of these
B
Correct answer
Explanation
The syntax int (*p)[10] declares p as a pointer to an array of 10 integers. The parentheses are crucial - without them, int *p[10] would be an array of 10 pointers. This pointer can point to entire arrays, not individual integers.
-
selection sort
-
bubble sort
-
insertion sort
-
merge sort
-
heap sort
C
Correct answer
Explanation
Insertion sort provides several advantages such as simple implementation, efficient for (quite) small data sets, more efficient in practice than most other simple quadratic (i.e., O(n2)) algorithms such as selection sort or bubble sort, adaptive, i.e., efficient for data sets that are already substantially sorted: the time complexity is O(nk) when each element in the input is no more than k places away from its sorted position, stable; i.e. does not change the relative order of elements with equal keys, in-place; i.e., only requires a constant amount O(1) of additional memory space,online; i.e., can sort a list as it receives it.