Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) PDF Download

  Q1: Let AA be an array containing integer values. The distance of AA is defined as the minimum number of elements in AA that must be replaced with another integer so that the resulting array is sorted in non-decreasing order. The distance of the array  [2,5,3,1,4,2,6] is _____   (2024 SET-  2)
(a) 1
(b) 2
(c) 3
(d) 4
Ans : (c)
Sol :
Given array: [2, 5, 3, 1, 4, 2, 6]
Indices:  0  1  2  3  4  5  6
Values:   2  5  3  1  4  2  6 
The array with sorted indices: 
Indices:  0  1  2  3  4  5  6
Values:   2  2  3  3  4  4  6
Number of elements out of order: 3

Q2: What is the worst-case number of arithmetic operations performed by recursive binary search on a sorted array of size n?  (2021 SET-2) 
(a)Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(b)Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(c)  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(d) Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Ans:(b)
Sol:

Worst-case number of arithmetic operations performed by recursive binary search on a sorted array is given by the following recurrence relation: 

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

Q3:  Let P be an array containing n integers. Let t be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of n elements. Which one of the following choices is correct?  (2021 SET1)
(a) Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(b) Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(c) 
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
(d) Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Ans: (c)
Sol :
The answer is a stub!

Tournament Method:

  • Imagine using merge sort and you’d divided the array elements in pairs of two, every element is compared with each other.
  • The largest(or smallest if preferred) is selected out each pairs and the winners are copied to a new array and the procedure it repeated till we have one element remaining.

 For this, 
At first we need  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)  comparisons(sincePrevious Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)  pairs), then Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) so on this sums to nn , an AP 

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

  • For finding the smallest element we would use the losers left out in the first round  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) n2 losers to be precise.
  • We again use this procedure with an intention for finding smaller amongst all, (worst losers will be the best winners in these rounds, ironical indeed).

For this,
We need, n4  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)at first since we are pitting losers against losers comparisons then,  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

so on which sums  uptoPrevious Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE).
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) 

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) 
The number  of comparisons needed is at least  Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) 32n if we consider the elements to be distinct. 

Q4:  If an array A contains the items 10,4, 7,23,67,12 and 5 in that order, what will be the resultant array A after third pass of insertion sort?   (2020)
(a)  67,12,10,5,4,7,23
(b)  4,7,10,23,67,12,5
(c)  4,5,7,67,10,12,23
(d)  10,7,4,67,23,12,5 

Ans:(b)
Sol:

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
 Pass1 1will be applied on the first 2 2elements. 

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)
Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

Q5:  Consider a 2-dimensional array x with 10 rows and 4 columns, with each element storing a value equivalent to the product of row number and column number. The array is stored in row-major format. If the first element x[0] [0] occupies the memory location with address 1000 and each element occupies only one memory location, which all locations (in decimal) will be holding a value of 10?  (2020
(a) 1018,1091
(b)  1022,1041
(c)  1017,1036
(d)  1000,1399
Ans: (c)
Sol:  
we can only get 10 from following combinations:
1*10--NOT POSSIBLE
2*5--NOT POSSIBLE 
5*2--POSSIBLE (x[4][1]) 
x[9][0] = 9*4+ 0+1000 = 1036 
x[4][1]=4*4+1+1000=1017

n

Comparisons Req. for finding the Min Element..=n4+n8+n16...=n2

Total Number of Comparisons Number Required=n+n2=3n2

The document Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE) is a part of the Computer Science Engineering (CSE) Course Programming and Data Structures.
All you need of Computer Science Engineering (CSE) at this link: Computer Science Engineering (CSE)
119 docs|30 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on Previous Year Questions: ARRAY - Programming and Data Structures - Computer Science Engineering (CSE)

1. What is an array in computer science?
Ans. An array in computer science is a data structure that stores a collection of elements of the same data type in contiguous memory locations. Each element in the array is accessed by its index.
2. How is an array different from a linked list?
Ans. An array stores elements in contiguous memory locations, allowing for fast random access. In contrast, a linked list stores elements in non-contiguous memory locations connected by pointers, making sequential access faster but random access slower.
3. What is the time complexity for accessing an element in an array?
Ans. The time complexity for accessing an element in an array is O(1) as it can be done in constant time by directly accessing the element's memory location using its index.
4. Can the size of an array be changed dynamically in most programming languages?
Ans. No, the size of an array is usually fixed upon initialization in most programming languages. If dynamic sizing is required, other data structures like dynamic arrays or lists can be used.
5. How can we initialize an array in programming languages like C++ or Java?
Ans. In C++, an array can be initialized using braces {} with the elements separated by commas. In Java, an array can be initialized using the new keyword followed by the type and size of the array.
119 docs|30 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Semester Notes

,

Important questions

,

Free

,

Previous Year Questions with Solutions

,

MCQs

,

pdf

,

Viva Questions

,

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

,

Objective type Questions

,

shortcuts and tricks

,

past year papers

,

mock tests for examination

,

Sample Paper

,

practice quizzes

,

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

,

Extra Questions

,

Summary

,

study material

,

ppt

,

video lectures

,

Previous Year Questions: ARRAY | Programming and Data Structures - Computer Science Engineering (CSE)

,

Exam

;