Computer Knowledge
Data Structures and Algorithms
1,518 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
-
Deque
-
Priority
-
Tree
-
All of above
C
Correct answer
Explanation
Trees are the standard data structure for representing hierarchical relationships because each node can have multiple children, forming a parent-child hierarchy. Deques (double-ended queues) are linear structures for adding/removing from both ends, not hierarchies. Priority queues are for ordered access by priority, not hierarchy. Option C is correct.
-
Complete binary tree
-
Binary search tree
-
Extended binary tree
-
None of above
C
Correct answer
Explanation
An extended binary tree (also called a full binary tree or proper binary tree) is defined as a binary tree where every node has either 0 or 2 children - never just 1 child. A complete binary tree fills all levels except possibly the last, which must be left-filled. A binary search tree is ordered by key values, not by child count. Option C is correct.
-
a) INDEXED
-
b) NUMBERED
-
c) LINEAR
-
d) NONINDEXED
A
Correct answer
Explanation
KSDS (Key Sequenced Data Set) organizes data using an INDEXED structure. Records are stored and accessed based on their key values, which are maintained in a separate index component. This indexed organization enables efficient direct access by key. Option A is correct.
-
Arrays
-
Records
-
Pointers
-
None
A
Correct answer
Explanation
Arrays are designed to store homogeneous data elements - all elements must be of the same type. Records can store heterogeneous data (different types), pointers store addresses (not data elements per se), and 'None' is incorrect. Therefore Arrays is the correct answer.
-
Arrays
-
Records
-
Pointers
-
None
B
Correct answer
Explanation
Records are designed to store heterogeneous data elements - fields can be of different types (e.g., name:string, age:integer, salary:decimal). Arrays require homogeneous elements. Pointers store addresses. Therefore Records is the correct answer.
-
elementary items
-
atoms
-
scalars
-
all of above
D
Correct answer
Explanation
Indecomposable items in a record that cannot be broken down further are called elementary items, atoms, or scalars - all three terms refer to the same concept of primitive data types that contain a single value. Therefore 'all of the above' is correct.
-
linear arrays
-
linked lists
-
both of above
-
none of above
A
Correct answer
Explanation
Linear arrays are indexed structures because they allow direct access to any element using its index in constant time O(1). The index is used to calculate the memory address directly. Linked lists are sequential structures that require traversal from the head to access a specific element, making them non-indexed.
-
The list must be sorted
-
there should be the direct access to the middle element in any sublist
-
There must be mechanism to delete and/or insert elements in list
-
none of above
C
Correct answer
Explanation
Binary search requires the search space/list to be sorted and allows random access to the middle element to achieve logarithmic time complexity. It does not require a mechanism to insert or delete elements; in fact, binary search is often performed on static arrays.
-
must use a sorted array
-
requirement of sorted array is expensive when a lot of insertion and deletions are needed
-
there must be a mechanism to access middle element directly
-
binary search algorithm is not efficient when the data elements are more than 1000.
D
Correct answer
Explanation
Binary search has O(log n) time complexity, which remains efficient even for large datasets. The efficiency depends on the logarithmic growth rate, not on a fixed number like 1000. Options A, B, and C are actual limitations: binary search requires sorted data and direct access to the middle element, which can be expensive to maintain with frequent insertions/deletions.
-
tables arrays
-
matrix arrays
-
both of above
-
none of above
C
Correct answer
Explanation
Two-dimensional arrays are commonly referred to as both tables (for tabular data representation) and matrices (especially in mathematical contexts involving rows and columns). Both terms describe the same conceptual structure of data arranged in a grid format with rows and columns.
-
LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array
-
LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array
-
LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array
-
None of above
A
Correct answer
Explanation
The address of any array element is calculated as: Base Address + (Index - Lower Bound) × Word Size. For the 5th element, this is LOC(Array[5]) = Base(Array) + w(5 - lower bound), where w represents bytes per memory cell. Options B and C are incorrect because they omit the word size multiplier or use wrong bounds.
-
Linked lists
-
Stacks
-
Queues
-
Deque
D
Correct answer
Explanation
A deque (double-ended queue) specifically allows insertion and deletion at both ends. Stacks only allow operations at one end (LIFO), queues restrict insertion to rear and deletion to front (FIFO), and linked lists allow insertion/deletion anywhere but not with the same efficiency at both ends as a deque.
-
FAEKCDBHG
-
FAEKCDHGB
-
EAFKHDCBG
-
FEAKDCHBG
B
Correct answer
Explanation
The inorder sequence E A C K F H D B G and preorder F A E K C D H G B correspond to a specific binary tree structure. Preorder traversal always visits root first, then left subtree, then right subtree. Option B is the correct preorder for this tree configuration.
-
grounded header list
-
circular header list
-
linked list with header and trailer nodes
-
none of above
D
Correct answer
Explanation
A two-way list (doubly linked list) has nodes with pointers to both next and previous nodes. None of the given options (grounded header list, circular header list, linked list with header and trailer) specifically describe a doubly linked list. These are variations of singly linked lists or specific implementations, not two-way lists.
-
An array is suitable for homogeneous data but hte data items in a record may have different data type
-
In a record, there may not be a natural ordering in opposed to linear array.
-
A record form a hierarchical structure but a lienear array does not
-
All of above
D
Correct answer
Explanation
Arrays store homogeneous elements (same type) with natural ordering by index. Records can store heterogeneous elements (different types) without requiring a natural ordering among fields. Records can form hierarchical structures through nested records, unlike simple linear arrays. All three statements correctly distinguish arrays from records.