Tuesday 15 September 2020

Stack Operations

 Stack Operations


push() − Pushing (storing) an element on the stack.


pop() − Removing (accessing) an element from the stack.


peek() or Top() − get the top data element of the stack, without removing it.


PEEP() To find nth element from stack.


PEEP(Stack_s1, TOP, i) 

 //Check for Stack Underflow 

If(TOP-i+1 < 0) then 

 Write (‘Stack Underflow For PEEP’) 

 Return 

  //Return ith element from top of stack 

Return Stack_s1 [Top – i + 1] 


isFull() − check if stack is full.


isEmpty() − check if stack is empty.


push(), pop(), isEmpty() and peek() etc. all take O(1) time. We do not run any loop in any of these operations.

Saturday 12 September 2020

Array Address Calculation Questions

 


1. 

An array X [-15……….10, 15……………40] requires one byte of storage. If beginning location is 1500 determine the location of X [15][20].

2.

A matrix B[10][20] is stored in the memory with each element requiring 2 bytes of storage. If the base address at B[2][1] is 2140, find the address of B[5][4] when the matrix is stored in Column Major Wise.


3.

Each element of an array arr[15][20] requires ‘W’ bytes of storage. If the address of arr[6][8] is 4440 and the base address at arr[1][1] is 4000, find the width ‘W’ of each cell in the array arr[][] when the array is stored as Column Major Wise.

4.

A matrix ARR[-4…6, 3…8] is stored in the memory with each element requiring 4 bytes of storage. If the base address is 1430, find the address of ARR[3][6] when the matrix is stored in Row Major Wise.


5. 

A matrix A[m][m] is stored in the memory with each element requiring 4 bytes of storage. If the base address at A[1][1] is 1500 and the address of A[4][5] is 1608, determine the order of the matrix when it is stored in Column Major Wise.


6. 

A matrix P[15][10] is stored with each element requiring 8 bytes of storage. If the base address at P[0][0] is 1400, determine the address at P[10][7] when the matrix is stored in Row Major Wise.


7. 

 A matrix A[m][n] is stored with each element requiring 4 bytes of storage. If the base address at A[1][1] is 1500 and the address at A[4][5] is 1608, determine the number of rows of the matrix when the matrix is stored in Column Major Wise.


8. 

The array D[-2…10][3…8] contains double type elements. If the base address is 4110, find the address of D[4][5], when the array is stored in Column Major Wise.


9.

An array AR[-4 … 6, -2 … 12], stores elements in Row Major Wise, with the address AR[2][3] as 4142. If each element requires 2 bytes of storage, find the Base address.


10. 

A square matrix M[][] of size 10 is stored in the memory with each element requiring 4 bytes of storage. If the base address at M[0][0] is 1840, determine the address at M[4][8] when the matrix is stored in Row Major Wise.


11.

A matrix B[10][7] is stored in the memory with each element requiring 2 bytes of storage. If the base address at B[x][1] is 1012 and the address at B[7][3] is 1060, determine the value ‘x’ where the matrix is stored in Column Major Wise


12. 

A square matrix A [m × m] is stored in the memory with each element requiring 2 bytes of storage. If the base address at A[1][1] is 1098 and the address at A[4][5] is 1144, determine the order of the matrix A[m × m] when the matrix is stored in Column Major Wise


13. 

A character array B[7][6] has a base address 1046 at 0, 0. Calculate the address at B[2][3] if the array is stored in Column Major Wise. Each character requires 2 bytes of storage.


14.

Each element of an array A[20][10] requires 2 bytes of storage. If the address of A[6][8] is 4000, find the base address at A[0][0] when the array is stored in Row Major Wise.


15.

A two-dimensional array defined as X[3…6, -2…2] requires 2 bytes of storage space for each element. If the array is stored in Row Major Wise order, determine the address of X[5][1], given the base address as 1200.



Ans:


1    1660, 2285

2    2206

3    4

4    1610

5    6

6    2256

7    6

8     4366

9    3952

10    2032

11    3

12    5

13    1092

14    3864

15.    1226

Wednesday 9 September 2020

MCQ Questions on Sorting



What is the best time complexity of bubble sort?

A N^2

B NlogN

C N

D N(logN)^2


Assume that we use Bubble Sort to sort n distinct elements in ascending order. When does the best case of Bubble Sort occur?

A When elements are sorted in ascending order

B When elements are sorted in descending order

C When elements are not sorted by any order

D There is no best case for Bubble Sort. It always takes O(n*n) time


The number of swappings needed to sort the numbers 8, 22, 7, 9, 31, 5, 13 in ascending order, using bubble sort is

A 11

B 12

C 13

D 10


Suppose we have a O(n) time algorithm that finds median of an unsorted array. Now consider a QuickSort implementation where we first find median using the above algorithm, then use median as pivot. What will be the worst case time complexity of this modified QuickSort.

A O(n^2 Logn)

B O(n^2)

C O(n Logn Logn)

D O(nLogn)


Which of the following is not a stable sorting algorithm in its typical implementation.

A Insertion Sort

B Merge Sort

C Quick Sort

D Bubble Sort


Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

A Quick Sort

B Heap Sort

C Merge Sort

D Insertion Sort


Consider a situation where swap operation is very costly. Which of the following sorting algorithms should be preferred so that the number of swap operations are minimized in general?

A Heap Sort

B Selection Sort

C Insertion Sort

D Merge Sort


Which of the following is not true about comparison based sorting algorithms?

A The minimum possible time complexity of a comparison based sorting algorithm is O(nLogn) for a random input array

B Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared

C Counting Sort is not a comparison based sorting algortihm

D Heap Sort is not a comparison based sorting algorithm.



Suppose we are sorting an array of eight integers using quicksort, and we have just finished the first partitioning with the array looking like this:
2  5  1  7  9  12  11  10 

Which statement is correct?

A The pivot could be either the 7 or the 9.
B The pivot could be the 7, but it is not the 9
C The pivot is not the 7, but it could be the 9
D Neither the 7 nor the 9 is the pivot



You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?
A Heap sort
B Merge sort
C Quick sort
D Insertion sort



Which sorting algorithm will take least time when all elements of input array are identical? Consider typical implementations of sorting algorithms.
A Insertion Sort
B Heap Sort
C Merge Sort
D Selection Sort

Which of the following sorting algorithms has the lowest worst-case complexity?
A Merge Sort
B Bubble Sort
C Quick Sort
D Selection Sort


Which sorting algorithms is most efficient to sort string consisting of ASCII characters?
A Quick sort
B Heap sort
C Merge sort
D Counting sort

Which of the following is true about merge sort?
A Merge Sort works better than quick sort if data is accessed from slow sequential memory.
B Merge Sort is stable sort by nature
C Merge sort outperforms heap sort in most of the practical situations.
D     All of the above.


Given an array where numbers are in range from 1 to n^6, which sorting algorithm can be used to sort these number in linear time?
A Not possible to sort in linear time
B Radix Sort
C Counting Sort
D Quick Sort

Sunday 30 August 2020

30 August Test Result



30 August 2020 Test Result

S.No.  
Name 
Marks  
1
Neety Yadav
46
2
Divya
46
3
Dilip Gupta
45
4
Salvi Vatsa
44
5
Poonam
44
6
Preeti
44
7
Raj Kumar Gupta
44
8
Manish Kumar  Garg
42
9
Rakesh
42
10
Sonika Kumari
42
11
Manasi Adhikary
42
12
Pritam Kumari
40
13
Shahib
40
14
Kirti
38
15
Anil Yadav
38
16
Shivam Sharma
38
17
Himanshu
37
18
Preeti
36
19
Sonia
36
20
Sanjeev
36
21
Abhishek Mishra
35
22
Vibhakar
34
23
Surya
34
24
Vibha
34
25
Ranjeet Yadav
34
26
Lovely
32
27
Satyam
32
28
Deepanshu
31
29
Khushbu
30
30
Shubham
30
31
Sachin
29
32
Manoj Kumar
28
33
Poonam Yadav
28
34
Md Tehran
28
35
Abhay
28
36
Aminur Rehman
27
37
Jyoti Malik
26
38
Sunny Goswami
26
39
Mohd Asif
25
40
Hansra
25
41
Karann
24
42
Kanchan
24
43
Amita
22
44
Vijay Kharb
22
45
Urvashi
21
46
Priyanka Soni
20
47
Sapna Sansanwal
20
48
Anuj Kashyap
20
49
Nitish Kumar
20
50
Rahul Kumar
20
51
Suhail Malik
19
52
Shlok
19
53
Alka Sharma
18
54
Bhanu
18
55
Hemant Kumar Singh
16
56
Sonam
14
57
Sunaina Bizenia
14
58
Ritesh
13
59
Ritesh
9
60
Amit Sharma
0

Sunday 16 August 2020

CSA Test Result

 CSA Test Result - 16 August 2020

Next Week Test Topic - C and C++

Check Daily Update of App - What new Upload and Change in App from this link. Check this daily.


S.No.
Name
Marks
1
Shivani Singh
46
2
Manasi Adhikary
42
3
Pooja Chaudhary
39
4
Divya
38
5
Subham Bhardwaj
37
6
Priya Chaurasia
36
7
Surya
35
8
Bhagwana Ram Meghwal
35
9
Pritam Kumari
34
10
Nancy Chaudhary
33
11
Poonam Kashyap
33
12
Sonika Beniwal
32
13
Kapil Kashyap
31
14
Suruchi
31
15
Sonam Nehra
31
16
Sachin Tehlan
29
17
Nidhi Beniwal
29
18
Meera Yadav
28
19
Amit Chauhan
28
20
Abhishek Mishra
28
21
Anushurti
28
22
Kirti Sagar
28
23
Hemant Kumar Singh
27
24
Manish Kumar Garg
27
25
Vibha Sharma
27
26
Sadab Khan
27
27
Ajay Kaushik
26
28
Seema Yada
26
29
Vibhakar
25
30
Lovely Verma
25
31
Sandhya
24
32
Priyanka Soni
24
33
Poonam Yadav
24
34
Kirti
24
35
Rakesh
23
36
Karan
23
37
Akshay Sharma
23
38
Vineeta
23
39
Sushmita
22
40
Sana Shaikh
22
41
Deepanshu
22
42
Sunny
22
43
Vijay Kushawah
21
44
Ritika Pandey
21
45
Dilip Gupta
21
46
Sunaina Bizenia
21
47
Rajpal Singh
21
48
Monika Yadav.
20
49
Ankur Bhardwaj
20
50
Alpana Saharawat
20
51
Jyoti Malik
18
52
Manoj Kumar
17
53
Kalyani
16
54
Pallavi kumari
16
55
Vipin Sharma
16
56
Khushbu
16
57
Akansha
16
58
Nisha Dagar
15
59
Ashish Bisht
15
60
Govil
14
61
Rahul
14
62
Sandeep Kumar
12
63
Sweta
12
64
Sonam Singh
9
65
Manu
9
66
Raj
8
67
Jagjeet Singh
8
68
Ishant
8
69
Rashmika Kataria
5
70
Anupama Jena
4