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

Multiple choice technology architecture
  1. FAEKCDBHG

  2. FAEKCDHGB

  3. EAFKHDCBG

  4. FEAKDCHBG

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. grounded header list

  2. circular header list

  3. linked list with header and trailer nodes

  4. none of above

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology architecture
  1. Arrays are dense lists and static data structure

  2. data elements in linked list need not be stored in adjecent space in memory

  3. pointers store the next data element of a list

  4. linked lists are collection of the nodes that contain information part and next pointer

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Option C is false because pointers store the ADDRESS of the next node, not the data element itself. Options A, B, and D are true: arrays are dense static structures, linked list elements need not be adjacent in memory (linked by pointers), and linked lists are collections of nodes with data and pointer fields.

Multiple choice technology architecture
  1. sorted linked list

  2. sorted binary trees

  3. sorted linear array

  4. pointer array

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Binary search requires O(1) direct access to the middle element, which is not possible in linked lists as they require sequential traversal. Binary search CAN be applied to sorted linear arrays (direct index access), sorted binary trees (balanced BSTs allow O(log n) access), and pointer arrays (also support direct access).

Multiple choice technology architecture
  1. FIFO lists

  2. LIFO list

  3. Piles

  4. Push-down lists

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Stacks operate on LIFO (Last In First Out) principle, meaning the last element added is the first one removed. FIFO (First In First Out) is the characteristic of queues, not stacks. LIFO, piles, and push-down lists are all names associated with stack data structures, while FIFO specifically describes queue behavior.

Multiple choice technology architecture
  1. array

  2. lists

  3. stacks

  4. all of above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Push and pop are the fundamental operations of stack data structures. Push adds an element to the top of the stack, while pop removes the top element. While stacks can be implemented using arrays or linked lists, the terms push and pop specifically refer to stack operations and are standard terminology for this abstract data type.

Multiple choice technology performance
  1. for (var i = 0; i < arr.length; i++) { // some code here }

  2. for (var i = 0, len = arr.length; i < len; i++) { // some code here }

  3. for (var i = arr.length; i--; ) { // some code here }

  4. for ( i = 0; i < arr.length; i++) { // some code here }

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A decrementing loop checking against zero (i--) is historically the fastest in JavaScript because the termination check does not require querying a property (arr.length) or comparing variables on every iteration. Other options perform redundant length lookups or property evaluations inside the loop condition.

Multiple choice technology
  1. Round Robin

  2. Same

  3. Hash

  4. Modulus

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

Keyless partitioning methods distribute or maintain data flow without requiring a key column value. Round Robin rotates rows sequentially across partitions without reading any field. Same partitioning preserves the existing partitioning from the previous stage without applying any key-based logic. In contrast, Hash and Modulus both require a key column to calculate partition assignments.

Multiple choice technology programming languages
  1. Vector

  2. Array List

  3. Linked List

  4. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

LinkedList is theoretically the fastest for inserting into the middle of a list because it only requires updating the pointers of neighboring nodes, which is an O(1) operation once located. Array-based structures like ArrayList and Vector require shifting all subsequent elements, which is an O(N) operation and significantly slower.

Multiple choice technology mainframe
  1. 01 ARRAYS. 05 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

  2. 01 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

  3. 01 ARRAYS. 05 ARRAY1 PIC X(9) OCCURS INDEX BY 10 TIMES

  4. 01 ARRAYS. 88 ARRAY2 PIC X(6) OCCURS 20 TIMES INDEXED BY WS-INDEX

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In COBOL, the OCCURS clause cannot be defined at the 01 level (ruling out the second option) or with level 88 condition names (ruling out the fourth). The third option uses incorrect syntax order. The first option correctly defines the table at level 05 with INDEXED BY.

Multiple choice technology
  1. uksort()

  2. arsort()

  3. ksort()

  4. All of the above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

PHP provides multiple sorting functions for different sorting needs. uksort() sorts by keys with a custom comparison, arsort() sorts by values in descending order, and ksort() sorts by keys in ascending order. All three are valid array sorting functions in PHP, making All of the above the correct choice.

Multiple choice technology
  1. Round Robin

  2. Same

  3. Hash

  4. Modulus

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

Round Robin distributes rows sequentially without using any key, and Same keeps data on the same partition (no key needed for repartitioning). Hash and Modulus both require a key column to calculate partition destinations.

Multiple choice technology
  1. key

  2. minor-key

  3. major-key

  4. max-core

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Sort within Group is used when data is already sorted by a major key and you need to sort within each group of that major key. The major-key parameter specifies the key that the input is already pre-sorted on, allowing the component to perform secondary sorting within each group efficiently.

Multiple choice technology
  1. int *array1 = (int *)malloc(nrows * sizeof(int *));

  2. int *array2 = (int *)malloc(nrows * sizeof(int *));

  3. int *array3 = (int *)malloc(nrows * ncolumns * sizeof(int));

  4. Any of the above.

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

All three methods are valid approaches to allocate 2D arrays dynamically. Option A allocates an array of pointers then each row separately (pointer-to-pointer). Option B appears identical to A in the garbled text but represents the same approach. Option C allocates a single contiguous block and uses arithmetic to index (flattened 2D array). Each has trade-offs in syntax and memory layout.