Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 1 MCQs Basic Data Structures

CSE329 — Prelude To Competitive Coding 60 questions. Pick an option to check it.

Read the notes Subjective questions

0 of 60 answered 0 right 0 wrong , 60 left

  1. Question 1 of 60 Arrays Easy

    What is the index of the first element in a standard array in languages like C, C++, and Java?

  2. Question 2 of 60 Declaring and processing 1D and 2D arrays Easy

    How many elements can a 2D array declared as int a[3][4] hold?

  3. Question 3 of 60 Insertion in an array Easy

    When inserting an element at the beginning of an array of elements, how many existing elements must be shifted?

  4. Question 4 of 60 Deletion from array Easy

    What is the worst-case time complexity of deleting an element from an array?

  5. Question 5 of 60 Array rotations Easy

    If the array is left-rotated by positions, what is the result?

  6. Question 6 of 60 Matrix multiplication Easy

    To multiply matrix of size with matrix , what must be true?

  7. Question 7 of 60 Lower triangular and upper triangular matrix of array Easy

    In an upper triangular matrix, which elements are zero?

  8. Question 8 of 60 Print a matrix in spiral form Easy

    When printing a matrix in spiral form, in which order are the boundaries typically traversed first?

  9. Question 9 of 60 String declaration and manipulation Easy

    In C, which character marks the end of a string stored in a character array?

  10. Question 10 of 60 Missing characters to make a string Pangram Easy

    A pangram is a sentence that contains:

  11. Question 11 of 60 Remove minimum number of characters so that two strings become anagram Easy

    Two strings are anagrams of each other if they:

  12. Question 12 of 60 Creation of stack using arrays Easy

    A stack follows which principle for insertion and removal of elements?

  13. Question 13 of 60 Creation of queue using array Easy

    A queue follows which order for processing elements?

  14. Question 14 of 60 Circular Queue Easy

    What advantage does a circular queue have over a simple linear queue implemented with arrays?

  15. Question 15 of 60 Implementation of Deque using circular array Easy

    In a deque (double-ended queue), insertion and deletion can be performed at:

  16. Question 16 of 60 Two pointer technique depicted by problem to find if there exists a pair in an unsorted array whose sum is equal to X Easy

    The two-pointer technique for finding a pair with a given sum is most efficiently applied to an array that is:

  17. Question 17 of 60 Finding a peak element in array Easy

    A peak element in an array is an element that is:

  18. Question 18 of 60 Find the majority element Easy

    In an array of size , the majority element is one that appears:

  19. Question 19 of 60 Find the first non-repeating element in a given array of integers Easy

    In the array , what is the first non-repeating element?

  20. Question 20 of 60 Move All Zeros to End of Array Easy

    After moving all zeros to the end of while keeping the order of non-zero elements, the result is:

  21. Question 21 of 60 Array rotations Medium

    An array arr = [1, 2, 3, 4, 5] is left-rotated by 2 positions. What is the resulting array?

  22. Question 22 of 60 Insertion in an array Medium

    To insert an element at index in an array of size (with space available), how many elements must be shifted in the worst case?

  23. Question 23 of 60 Matrix multiplication Medium

    Two matrices of dimension and of dimension can be multiplied as only if:

  24. Question 24 of 60 Print a matrix in spiral form Medium

    For the matrix , what is the spiral order traversal starting from the top-left?

  25. Question 25 of 60 Lower triangular and upper triangular matrix of array Medium

    In a square matrix , an element belongs to the upper triangular part when:

  26. Question 26 of 60 Two pointer technique depicted by problem to find if there exists a pair in an unsorted array whose sum is equal to X Medium

    To use the two-pointer technique to find a pair summing to , what preprocessing step is required on an unsorted array?

  27. Question 27 of 60 Find the majority element Medium

    In the array [3, 3, 4, 2, 3, 3, 5, 3], which element is the majority element (appears more than times)?

  28. Question 28 of 60 Move All Zeros to End of Array Medium

    After moving all zeros to the end of [0, 1, 0, 3, 12] while keeping non-zero order, the result is:

  29. Question 29 of 60 Finding a peak element in array Medium

    A peak element is one that is greater than or equal to its neighbors. In [1, 3, 20, 4, 1, 0], which index holds a peak element?

  30. Question 30 of 60 Missing characters to make a string Pangram Medium

    A pangram contains every letter of the alphabet. For the string "the quick brown fox", how many distinct letters are missing to make it a pangram?

  31. Question 31 of 60 Remove minimum number of characters so that two strings become anagram Medium

    Given strings "bcadeh" and "hea", what is the minimum number of characters to remove from both so they become anagrams of each other?

  32. Question 32 of 60 Rearrange characters so that no two adjacent characters are same Medium

    For which string is it impossible to rearrange so that no two adjacent characters are the same?

  33. Question 33 of 60 Implement Stack using Queues Medium

    When implementing a stack using two queues with a costly push operation, what happens during a push?

  34. Question 34 of 60 Circular Queue Medium

    In a circular queue of size implemented with an array, after enqueue the rear pointer is updated as:

  35. Question 35 of 60 Implement two Stacks in an array Medium

    When implementing two stacks in a single array of size efficiently, where should the two stacks begin growing from?

  36. Question 36 of 60 Count subarrays having an equal sum of elements at even and odd positions Medium

    For counting subarrays where the sum of even-indexed elements equals the sum of odd-indexed elements, a common technique uses:

  37. Question 37 of 60 Rearrange array such that even index elements are smaller and odd index elements are greater Medium

    After rearranging [4, 3, 7, 8, 6, 2, 1] so that even-index elements are smaller than their odd-index neighbors (a wave-like pattern), which is a valid result?

  38. Question 38 of 60 Find the first non-repeating element in a given array of integers Medium

    In the array [9, 4, 9, 6, 7, 4], what is the first non-repeating element?

  39. Question 39 of 60 Last Moment Before All Ants Fall Out of a Plank Medium

    On a plank of length , ants moving toward each other pass through without changing direction. For finding the last moment before all ants fall off, the key insight is:

  40. Question 40 of 60 Reversing a Queue Medium

    Which data structure is most naturally used to reverse a queue while preserving the queue's FIFO interface?

  41. Question 41 of 60 Array rotations Hard

    An array A of size is left-rotated by positions using the reversal algorithm (reverse , reverse , then reverse the whole array). For and , what is the resulting array?

  42. Question 42 of 60 Print a matrix in spiral form Hard

    For an matrix printed in spiral order, how many direction-boundary shrink operations (adjusting top/bottom/left/right) occur in total during traversal?

  43. Question 43 of 60 Find the majority element Hard

    Using the Boyer-Moore Voting Algorithm on , what are the final candidate and count values just before the verification pass?

  44. Question 44 of 60 Implement two Stacks in an array Hard

    Two stacks are implemented in a single array of size using the space-efficient approach (stack1 grows from index 0, stack2 grows from index ). What is the correct overflow condition when pushing to either stack, given tops top1 and top2?

  45. Question 45 of 60 Remove minimum number of characters so that two strings become anagram Hard

    For strings s1 = "bcadeh" and s2 = "hea", what is the minimum number of characters to delete (from either string) to make them anagrams of each other?

  46. Question 46 of 60 Last Moment Before All Ants Fall Out of a Plank Hard

    On a plank of length , ants moving left are at positions and ants moving right are at . When two ants collide they reverse direction. What is the last moment before all ants fall off?

  47. Question 47 of 60 Two pointer technique depicted by problem to find if there exists a pair in an unsorted array whose sum is equal to X Hard

    To find whether a pair sums to in an unsorted array using the two-pointer technique, what preprocessing is required and what is the resulting overall time complexity?

  48. Question 48 of 60 Count subarrays having an equal sum of elements at even and odd positions Hard

    The trick to count subarrays where the sum of even-indexed and odd-indexed elements are equal is to negate elements at odd positions and then:

  49. Question 49 of 60 Finding a peak element in array Hard

    Binary search finds a peak element (an element its neighbors) in . If A[mid] < A[mid+1], which direction guarantees a peak exists?

  50. Question 50 of 60 Rearrange characters so that no two adjacent characters are same Hard

    A rearrangement of a string with no two adjacent equal characters is possible if and only if the maximum character frequency maxFreq satisfies which condition for a string of length ?

  51. Question 51 of 60 Design a stack with operations on middle element Hard

    To support push, pop, and findMiddle/deleteMiddle all in , which data structure is used and why?

  52. Question 52 of 60 Implementation of Deque using circular array Hard

    In a deque implemented with a circular array of capacity , indices front and rear, which expression correctly moves front backward during insertFront?

  53. Question 53 of 60 Implement Stack using Queues Hard

    When implementing a stack using a single queue, making push the costly operation, what is the sequence of steps for push(x) on a queue currently holding elements?

  54. Question 54 of 60 Missing characters to make a string Pangram Hard

    For the string "the quick brown fox" (ignoring spaces, lowercase), how many distinct letters must be added to make it a pangram?

  55. Question 55 of 60 Move All Zeros to End of Array Hard

    Using the two-pointer approach with a insertPos pointer, how many swaps occur for A = [0, 1, 0, 3, 12] while preserving the order of non-zero elements?

  56. Question 56 of 60 Check if all bits can be made same by single flip Hard

    A single flip means toggling exactly one contiguous group of adjacent same-bits. All bits can be made same by a single flip iff the number of 'groups' of consecutive equal bits is at most:

  57. Question 57 of 60 Lower triangular and upper triangular matrix of array Hard

    For an matrix, how many elements belong strictly to the upper triangular part (excluding the main diagonal)?

  58. Question 58 of 60 Find the first non-repeating element in a given array of integers Hard

    Which approach finds the first non-repeating element in optimal time, and what is that complexity for elements?

  59. Question 59 of 60 Rearrange array such that even index elements are smaller and odd index elements are greater Hard

    For a valid 'wave-like' arrangement where A[0] < A[1] > A[2] < A[3] > ..., which single-pass swapping rule achieves this in without sorting?

  60. Question 60 of 60 K maximum sum from two arrays Hard

    Given two sorted (descending) arrays, to find the maximum pairwise sums , the efficient approach uses a max-heap starting with which pair, and pushes which neighbors after each extraction?

That's unit 1

Answer a few questions and your score shows up here.