Assignment 3 Class XII (Computer Science 083) Topic Array 1. What is meant by base address of an array? 2. What are the preconditions for Binary Search to be performed on a single dimension array? 3. Calculate the address X[4,3] in a two dimensional array X[1.5, 1..4] stored in row major order in the main memory. Assume the base address to be 1000 and that each element requires 4 words of storage. 4. Given a two dimensional array A[10][20], base address of A being 100 and width of each element is 4 bytes, find the location of A[8][15], when the array is stored as a) Column Major b) Row Major. 5. Each element of an array A[-20..20, 10..35] requires 1 byte of storage. If the array is stored in column major order beginning location 500, determine the location of A[0,30]. 6. Each element of an array A[-15..20, 20..45] requires 1 byte of storage. If the array is stored in row major order beginning location 1000, determine the location of A[0,40]. 7. If 2 dimensional array C[5..10, -5..9] is stored using row major representation, then calculate the address if C[8,-2], if the base address is 10 and each array element requires 2 bytes of memory. 8. The following numbers: (25, 64, 48, 15, 34, 91, 88) are required to be sorted using a)selection Sort b) Insertion Sorts c) Bubble Sort, show how the list would appear at the end of each pass. 9. Write a program to display those elements of a two dimensional array T[4][4] which are divisible by 100. 10. Write a user defined function in c++ to find and display the sum of both the diagonals elements of a two dimensional array MATRIX[6][6] containing integers. 11. Write a menu driven program in C++ which will take 10 number and then sort the numbers using any sorting method of users choice like a) Insertion b) Selection c) Bubble. 12. Suppose A,B and C are arrays of size 8,9 and 17 respectively. Array A is stored in ascending order and array B is in descending order. WAP to produce a third array C, containing all the data of array s A and B in ascending order. 13. Given two arrays A and B, copy last five elements of B after first five elements of A to create another array C. Assume length of A and B is greater than five. 14. Write a C++ function (using most efficient searching method) to search for an item X in a sorted array of integers. 15. Given an array A[50] with base address 300 and element size 4 bytes. Find the address of A[10], A[25] and A[40] 16. Given an array named A with the following elements: 3, -5, 1, 3, 7, 0, -15, 3, -7, -8 write a c++ function to shift the negative to left and positive numbers to right so that the resultant array will look like: -5, -15, -7, -8, 3, 1, 3, 7, 0, 3 17. Write a program in C++ to interchange the values of the row and column. 18. Write a program in C++ to find the inverse of the matrix.
Assignment 6 Class XII (Computer Science 083) Topic Stack and Queues 1. Define a) Stack b) Queues 2. What is the difference between LIFO list and FIFO list? 3. What is the application of a) Stack b) Queue 4. What is the order of evaluations of arithmetic operator s? 5. What is the situation called when Deletion is attempted in an empty list? 6. What is the situation called when Insertion is attempted in a full list? 7. Given a stack as an array of 7 elements STACK: K, P, S, T, U, Y, B a) When will overflow and underflow occur? b) Can K be deleted before S, Why? 8. Write a menu driven program to Push, Pop and see the contents of stack (implementing array). 9. Write a menu driven program to Insert, delete and see the contents of queue (implementing array). 10. What is the difference between a general queue and the circular queue in the case of arrays? What is the advantage of circular queue and disadvantage of general queue? 11. Define a LINKED LIST. 12. What is the difference between STATIC and DYNAMIC Memory. 13. Write a menu driven program to Insert, delete and see the contents of stack (implementing linked list). 14. Write a menu driven program to Insert, delete and see the contents of queue (implementing linked list). 15. Distinguish between infix, prefix and postfix algebraic expressions giving examples of each. 16. Convert the following infix to postfix expression a) (A B) * (C / D) + E b) X + Y * Z ^ P - (X / Y + Z) c) A ^ B P / (Q * (A C + P * D) / B) d) A + B + C * D F G 17. Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation. a) t, f, t, f, NOT, OR, t, OR, OR, AND c) 12, 45, 82, *, d) 7, 87, 3, 2, ^, *, +, 15, 6, /, 8, +, d) 160, 6, 7, *, 4, 8, +, *, e) A + B * C + D * N ^ E / G H f) 60, 5, 9, /, 3, 8, +, *, 18. Define a) Singly Linked List b) Doubly Linked List c) Circular Linked List d) Dequeues 19. For a circular queue with 5 memory locations show diagrammatically the status of the front and rear after each of the following operations: i) 5, 4 and 3 inserted ii) 5 deleted iii) 9, 11 inserted iv) 4, 3 deleted v) 8, 6 inserted vi) 9 deleted vii) 25, 10 inserted viii) 11,4 deleted ix) 27 inserted x) 25, 10 deleted 20. Consider a queue of size 7 insert name Harsh, Nishu and then delete first name insert Chetan, Ankur, and delete first two names. Show the status of front and rear after each step.
Assignment 7 Class XII (Computer Science 083) Topic DBMS and SQL 1. Differentiate between SQL commands a) DROP Table and DROP View. b) Create table and Create View. 2. What is a relation? What is the difference between a tuple and an attribute? 3. Differentiate between DML (Data manipulation language) and DDL (Data definition language). 4. What is data redundancy? What are the problems associated with it? 5. What are the advantages of Relational Data Model? 6. Differentiate between Primary Key and Candidate Key. 7. What will be the precondition for applying Drop Table command? 8. What are the three different levels from the data can be abstracted? Explain all the 3. 9. Differentiate between Projection and Union operation. 10. Write the command to make the table a having following column heading and data types: - Name char(10) dob date roll number(2) sex char(1) best_sub char(9) 11. After entering at-least 10 records in the above table write the commands to: - a) Show the list of tables created earlier. b) Show the heading and their data types from the table a. c) Add a new column hobby having data type char and width 9. d) Add cooking in the hobby column for sex female. e) Add reading in the hobby column for sex male. f) Make a backup of table a by name b. g) Make a backup of table a by name c without best_sub column. h) Insert a new row in table as Srijan, 19/11/1987, 12, m, comp, reading. i) Remove the table c. j) Remove only those rows whose name starts with the character H. k) Delete all the rows of table b. l) Show the contents of name, roll and hobby column from table a. m) Show the contents of name and best subject of female students. n) Show the contents of name, hobby, date of birth and sex of female students or whose date of birth is less than 01.01.1986. o) Show the entire information of all the female students whose name starts with the character N. p) Show the entire information of all the male students whose name not starts with the character N. q) Display the list of best subject. r) Display the name, roll and hobby of those students whose roll is more than five and less than 10. (Without and with and command) s) Show the entire information of Nishu, Chetan and Harsh from the table.
t) Make two table Khushi and Snehal from table a. Table Khushi contains Roll, Name and date of birth while table Snehal contains Roll, Sex, Best Subject and Hobby columns. u) Delete the table a. v) Display Roll, Name, Sex, Date of birth, Best Subject and Hobby by combining the table Khushi and Snehal. w) Show Name and Sex from the table (Khushi and Snehal) by arranging the name in descending order. ------------------------------------------------------------------------------------------------------ Guess the output of the SQL commands based from the table Anu given below: - Roll Name Sex Phy Chem Comp. Total 10 Nishu F 60 60 65 12 Anshu F 55 40 60 14 Neha F 60 60 40 18 Chetan M 62 61 60 17 Harsh M 67 60 63 13 Pupul M 60 60 62 11 Ankur M 65 40 60 15 Preety F 62 68 63 16 Snehal F 55 60 70 19 Anuradha F 60 61 60 20 Gourav M 60 53 49 Before guessing the output please fill the total column using the suitable command x) Select avg(comp) from anu; y) Select max(phy+chem+math) from anu; z) Select name, max(total) from anu group by name; aa) Select name, max(total) from anu group by sex; bb) Select name, max(total) from anu group by total; cc) Select name, sex, max(total) from anu group by sex; dd) Select name, sex, max(total) from anu group by name, sex; ee) Select name, sex, max(total) from anu group by sex, name; ff) Select max(comp) from anu group by chem having chem<60; gg) Select max(comp) from anu group by chem having chem<=60; hh) Select max(comp) from anu group by chem having chem<=70; ii) Select * from anu order by name; jj) Select * from anu order by name, phy; kk) Select * from anu order by phy; ll) Select * from anu order by phy, name desc; mm) Select name, sex from anu group by sex, name; nn) Select phy from anu group by phy; oo) pp) Select distinct (phy) from anu; Select name, total, (total/210)*100 as Percent from anu order by Percent desc.
Assignment -8 XII File Handling Comp. 1. What are the different methods of opening a file? Explain in brief. 2. Differentiate between the functions write() and put() of the ostream class. 3. How can the end of file be detected? Explain in brief. 4. Differentiate between the function get(), put() and getline(). 5. How can you send an output to a printer? 6. WAP that counts the number of records in a given file. 7. WAP that appends the contents of one file to another. 8. WAP to add new objects at the bottom of a binary file STUDENT.DAT, assuming the binary file is containing the objects of the following class: - class STUD int Rno; char Name[20]; void enter() cin>>rno; gets(name); void display() cout<<rno<<name<<endl; ; 9. WAP to search for a book number from a binary file BOOK.DAT, assuming the binary file is containing the objects of the following class: - class BOOK int Bno; char title[20]; int Rbno() return Bno; void enter() cin>>bno; gets(title); void display() cout<<bno<<title<<endl; ; 10. WAP that reads 15 bytes from 35 th byte onwards from the file NIBBLE.
11. Assuming class OUTSTAND given below, write program to write objects having outamt more than Rs. 10,000 into CRITICAL file. class OUTSTAND int memno; float outamt; void getit() cin>>memno>>outamt; void putit() cout<<memno<<outamt; float getamt() return outamt; ; 12. Differentiate between ifstream class and outstream class. 13. Assuming the class STOCK, write program to perform following: - a) Write the objects of STOCK to a binary file. b) Read the objects of STOCK from binary file and display them on screen. class STOCK int ITNO; char ITEM[10]; void GETIT() cin>>itno; gets(item); void SHOWIT() cout<<itno<<item<<endl; ; 14. Explain the difference between put and write function. 15. Explain the difference between get and read function. 16. Why binary file is better than text file? 17. Explain seekg(), seekp(), tellg() and tellp() using suitable example for each. 18. WAP to count the number of lines present in a text file STORY.TXT. 19. WAP that reads a character from the keyboard one by one. All lower case characters get stored in a file LOWER, All upper case characters get stored in a file UPPER and all other characters get stored in the file OTHER. S.K.Jha (Faculty of Computer Science DAV) Sweet and Sour with Files