We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
Lab 4
Array - the Collection!
● Read about the previous lab session here.
● Writing code is like art; Do it beautifully with Indentation and Comments
1. Learn about arrays structure in c from here and here.
2. Take N numbers as input, and find the maximum and minimum element of those N numbers. (Can this question be done without array!) 2.1. Format: First line has N numbers, next line has N space-separated integers 3. Given N numbers, and Q queries, answer those queries. 3.1. First lines has N, the second line has N space-separated integers 3.2. The third line has Q 3.3. Next Q lines have two space-separated integers L R, output the sum of all numbers at indices L <= i <= R, 0 <= L, R < N (L, R are zero-indexed) 3.4. 1 <= N <= 106 , 1 <= Q <= 106 4. Given sorted array of N integers and Q queries each containing X, find if X exist in array and return its index. If it doesn’t exist, return -1 4.1. First lines has N, the second line has N space-separated integers 4.2. The third line has Q 4.3. Next Q lines have one integers each, X 4.4. The array would be sorted in increasing order 4.5. 1 <= N <= 106 , 1 <= Q <= 106 5. (Modular arithmatic, to be submitted on OJ, deadline 10PM tonight, not graded). Given T test cases and each test case has three integers inputs X,Y, M, find XY % M. 5.1. 1 <= T <= 106 , 0 <= X, Y <= 109 , 1 <= M <= 2 * 109