CSE101 array/data structure questions and answers Graded A+
CSE101 array/data structure questions and answers Graded A+ Given an integer x and an array of numbers, find if two numbers in the array sum up to x. (Or, find the pair of numbers whose sum is closest to x.) - Array A[n], x 1.) Sort using Mergesort ------- O(nlogn) 2.) Initialize two index variables to find candidit a.) Initialize first to the leftmost index: l = 0 b.) Initializ second the rightmost index: r = n - 1 3.) While l r -----------O(n) a.) if A[l] + A[r] == x; return true b.) else if A[l] + A[r] sum; increm
Written for
- Institution
- CSE 2221
- Course
- CSE 2221
Document information
- Uploaded on
- April 8, 2026
- Number of pages
- 16
- Written in
- 2025/2026
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cse101 arraydata structure questions and answers