Unit 1. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6]



Similar documents
DATA STRUCTURES USING C

10CS35: Data Structures Using C

PES Institute of Technology-BSC QUESTION BANK

Data Structure [Question Bank]

Krishna Institute of Engineering & Technology, Ghaziabad Department of Computer Application MCA-213 : DATA STRUCTURES USING C

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT. Course Curriculum. DATA STRUCTURES (Code: )

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

COMPUTER SCIENCE. Paper 1 (THEORY)

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LESSON PLAN

AP Computer Science AB Syllabus 1

AP Computer Science Java Mr. Clausen Program 9A, 9B

Sample Questions Csci 1112 A. Bellaachia

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

Analysis of a Search Algorithm

ML for the Working Programmer

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

BCS2B02: OOP Concepts and Data Structures Using C++

B.Sc.(Computer Science) and. B.Sc.(IT) Effective From July 2011

Syllabus for Computer Science. Proposed scheme for B.Sc Programme under Choice Based Credit System

Data Structures. Level 6 C Module Descriptor

Binary Heap Algorithms

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Bangalore University B.Sc Computer Science Syllabus ( Semester System)

COMPUTER SCIENCE 1999 (Delhi Board)

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

I PUC - Computer Science. Practical s Syllabus. Contents

Abstract Data Type. EECS 281: Data Structures and Algorithms. The Foundation: Data Structures and Abstract Data Types

Lab Manual. Data Structures (Pr): COT-213 Data Structures (P): IT-215

Basic Programming and PC Skills: Basic Programming and PC Skills:

To My Parents -Laxmi and Modaiah. To My Family Members. To My Friends. To IIT Bombay. To All Hard Workers

Introduction to Data Structures

Data Structure with C

Stack & Queue. Darshan Institute of Engineering & Technology. Explain Array in detail. Row major matrix No of Columns = m = u2 b2 + 1

What Is Recursion? Recursion. Binary search example postponed to end of lecture

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

Data Structures and Data Manipulation

Binary Search Trees. A Generic Tree. Binary Trees. Nodes in a binary search tree ( B-S-T) are of the form. P parent. Key. Satellite data L R

Pseudo code Tutorial and Exercises Teacher s Version

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

Atmiya Infotech Pvt. Ltd. Data Structure. By Ajay Raiyani. Yogidham, Kalawad Road, Rajkot. Ph : ,

Lecture 12 Doubly Linked Lists (with Recursion)

Objected oriented Programming: C++ Unit 1 1. Introduction 1.1. Introduction to Object Oriented Programming C++ fundamentals.

Module 2 Stacks and Queues: Abstract Data Types

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

Common Data Structures

Stacks. Linear data structures

Java Software Structures

6. Standard Algorithms

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Sources: On the Web: Slides will be available on:

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

Curriculum Map. Discipline: Computer Science Course: C++

Sorting Algorithms. Nelson Padua-Perez Bill Pugh. Department of Computer Science University of Maryland, College Park

Lecture 11 Array of Linked Lists

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap

7.1 Our Current Model

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Algorithms and Abstract Data Types

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

recursion, O(n), linked lists 6/14

Informatica e Sistemi in Tempo Reale

CSC148 Lecture 8. Algorithm Analysis Binary Search Sorting

CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

Algorithms and Data Structures

Algorithms. Margaret M. Fleck. 18 October 2010

Sorting revisited. Build the binary search tree: O(n^2) Traverse the binary tree: O(n) Total: O(n^2) + O(n) = O(n^2)

Recursion. Definition: o A procedure or function that calls itself, directly or indirectly, is said to be recursive.

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

12-6 Write a recursive definition of a valid Java identifier (see chapter 2).

1. Define: (a) Variable, (b) Constant, (c) Type, (d) Enumerated Type, (e) Identifier.

Data Structures, Practice Homework 3, with Solutions (not to be handed in)

/* File: blkcopy.c. size_t n

Algorithm Analysis [2]: if-else statements, recursive algorithms. COSC 2011, Winter 2004, Section N Instructor: N. Vlajic

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

As previously noted, a byte can contain a numeric value in the range Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

An Introduction to Programming and Computer Science

Coding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Why? A central concept in Computer Science. Algorithms are ubiquitous.

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

1 Abstract Data Types Information Hiding

LINKED DATA STRUCTURES

The C Programming Language course syllabus associate level

A COMPARATIVE STUDY OF LINKED LIST SORTING ALGORITHMS

Data Structures. Topic #12

Unordered Linked Lists

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays:

Transcription:

Unit 1 1. Write the following statements in C : [4] Print the address of a float variable P. Declare and initialize an array to four characters a,b,c,d. 2. Declare a pointer to a function f which accepts integer as parameter and dose not return anything. 3. Read a string which will contain only alphabets. 4. Write a C program using pointers and functions to: [6] i. Read a string ii. Append a string to another string iii. Copy a string to another string. 5. Write iterative and recursive C functions to find the greatest common divisor of two integers. [6] 6. What is pointer in C? Write the output of the following code: [6] main() static int a[]=10,20,30,40,50; int *ptr=a; static int arr[2][2]=1,2,3,4; char str[]= ABCD * 4# ; char *s= str+2; int I,j; for(i=0;i<5,i++) printf( %d, * ptr++); for (i=0;i<2;i++) for(j=0;j<2;j++) printf( %d \,n, *(*(n+i)+j)); printf( %c\n%c\n%c\n, *(str + 2),*s++,*--s);

7. Write a C program to count the number of special characters and lines in a text file and append it to same file. [6] 8. Differentiate between the following: [4] (i) Call by value and call by reference (ii) Structure and union. 9. What is similarity between structure, union and enumeration? [6] 10. What is Macro? What are its advantages and disadvantages. [6] 11. Write a C program to interchange two variables without using third variable. [4] 12. Describe about storage allocation and scope global, extern, static, local and register variables. [8] 13. What do you mean by type- definition? Explain with example. [4] 14. Determine output of the following C statement: [4] main() int x=10,y=5,p,q; P=x>9; q=x>3 && y!=3; printf( p=% d,q= % d,p,q); main() int x; X= -3+4-7*8/5%10; printf( x=%d,x); 15. Write a recursive function to display nth element in Fibonacci series. With the help of stack contents give a trace of Fibonacci function by you for n=6; [6] 16. Explain the following with example with respect to files in C :[10] i. Fread ii. Fwrite iii. Fseek iv. Ftell v. Fopen 17. What is the difference between text files and binary files? [6]

18. Write C function to reverse the n numbers stored in one dimensional array. [5] 19. What is recursive function? Explain with example. [5] 20. Explain the following concept in C language with example.[8] (i)pointer (ii)call by value (iii)array of pointers (iv)structure 21. Write a C program to perform following operations on an array of integers of size n.using functions with parameters: [8] (i) Delete an element at a given position (ii) Count and display the prime numbers. 22. (a) Write output of code: [8] #include<stdio.h> #define N 5 int main( ) Int I,j,n=N; Int *p,list[]=10,20,30,40,50; Char name[][4]= ABC, BCD, CDE; Char (*q)[4]; P= &list[0]; Q=&name[0]; for(i=0;i<n;) print( %d \t %d \n,*(list+i++),*(p++)); for (j=0;j<3;j++) printf( %s \t %c\t%d\n,name[j],*(*(q)+j),name[j][0]); 23. Write a C program to read and store data about n machine parts in a file. The data of each machine part consists of a part

24. Machine part consist of a part number, name and quantity. Write a C function to display the total quantity of all parts and the part numbers having quantity less than given value.[8] 1. (a) Define the following terms: [4] Unit 2 i. Data structure ii. Pseudocode iii. Abstract data types iv. Big O notation 2. Write an algorithm to find the sum of integers in an array of size n and explain algorithm components with respect to your algorithm. [6] 3. Explain the classification of data structures with an example each [6]. 4. Give the basic statement constructs in an algorithm with example. [4] 5. Write iterative algorithm to find the factorial of a number. Determine the efficiency of your algorithm. [6] 6. Find the frequency count of each statement and each statement determine the time complexity of code given below: [6] Main() printf( %d,m); printf( %d,n); for (i=0;i<=m;i++) for(j=0;j<=n;j++) Count++; a+=b[count]; 7. Define Pointers? How do we declare the pointers?give its advantages. [6]

8. Diffrentiate between pass by reference and pass by value. [4] 9. Explain the effect of following statements: 1. int p,*p; 2. int q,*p=&q; 3. int(*p)++; 4. char *p; 5. int a=*p+5; 10. What is difference between null pointer and null macro? [6] 11. What are pointers really good for? [4] 12. What is recursion? Explain with example. [6] 13. Define algorithm? What are the characteristics of an algorithm? [6] 14. What is the frequency count of following: int fact(int n) int ans=1; while(n>=1) Ans=ans*n; N=n-1; Return(ans);. 15. Find out complexity? Explain linear,non linear data structure,static and dynamic data structure. [4] 16. What is abstract data types?write An ADT for an array? [6] 17. Find frequency count of each step in code: int i,j; for(i=1;i<=n;i++) for (j=1;j<=n;j++) C[i][j]=a[i][j]+b[i][j]; 18. Explain Big O,Sigma and theta notation with example? [4]

19. Explain the following terms with example: i. Static data structure ii. Omega notation iii. Flow charts iv. Data object 20. Write an algorithm to find sum of odd and even int in an array of integers of size n. [8] 21. Determine the efficiency of algorithm for finding minimum number from list using frequency count. [8] 22. Give the classification of data structures with respect to memory allocation and relation between elements. [8] Unit 3 1. Write an ADT for polynomial. Write pseudocode for 2-polynomial addition using arrays. Find out time complexity of it. [12] 2. Derive the formula to calculate the address of the element in one-dimensional and twodimensional array using row major representation. [6] 3. Explain the steps of fast transpose algorithm for getting the transpose of sparse matrix having maximum m rows and n columns. What is the time complexity and space complexity of it? What are the advantages of fast transpose over simpletranspose? [10] 4. Write an ADT for sparse matrix. [4] 5. What is row major and column major storage representation methods of an array? [4] 6. What is call by value and call by reference? Explain with one example for each. [8] 7. Write a C program to shift elements of an integer array one location ahead. Element present at last location of array should be shifted on first location of the array. Write separate functions for accepting array, shifting array, displaying array etc. [8] 8. Explain execution of the following code step by step and show the final output : [8] # include < stdio.h > void display (int); int main( ) int x = 4;

display (x); return 0; void display (int n) if (n > 0) display (n 1); printf ( %d, n); 9. Write a C program to implement a structure for automobile part with data members part number, part name, quantity etc. Write separate functions for initializing structure, updating structure, displaying structure etc. [8] 10. Wtite polynomial as ADT.Represent the following polynomials using Array: 5x 11. Write Psedo C algorithm to find the fast transpose of a sparse matrix.analyse the time complexity of the algorithm.[6] 12. Derive the address calculation formula for multidimentional array, A[u1][u2]..[un] in row major and coloumn majior representation.[6] 13. Justify array as a linear data structure.write ADT for an array[6] 14. Write psedo c algorithm to add two polynomials represented using array and analyse the time complexity[6] 15. Explain the representation of sparse matrix with an example and state its advantages.[6] 16. Define time and space complexity of an algorithm[6] 17. Explain with the example linear data structure[6] 18. Define the following terms: [4] (i)data object (ii)data type 19. What is an abstract data type? [2] 20. Define data structure.what are different types of data structure? Explain.[8]

21. Explain different asymptotic notation.[4] 22. What do you mean by frequency count and its importance in the analysis of algorithm[6] UNIT 4 1. Write pseudocode for searching an element in a given array using linear search. What is the time complexity of linear search in best case, average case and worst case? Explain with example. [8] 2. Write a pseudocode for quicksort to sort a given array of n numbers. Show the contents of an array after each iteration for the following array : 79 100 59 40 20 10 What is worst case and average case time complexity of quicksort? [8] 3. Write an algorithm for shell sort. Apply your algorithm to sort the following numbers in ascending order. Show the contents of an array after every iteration : 4 66 1 74 22 41 36 54 64 What is time and space complexity of shell sort? [8] 4. Write pseudocode for Fibonacci search. Apply your algorithm on the following data to search numbers : 9, 100, 10. [8] 9 17 23 38 45 50 57 76 79 90 100 5. Explain Generalized Linked List (GLL) with node structure in C. Represent the following using GLL : (a, b, c, (d, (e, f, c)), g), h, i). [10] 6. Write a function to create singly linked list which is sorted while creation. [6] 7. Explain in detail the concept of data object, data structures, linear data structure and nonlinear data structure. [8] 8. What is Asymptotic notation? Write an algorithm for matrix multiplication for n n matrix and find out its time complexity by frequency count. [8] 9. What is Abstract Data Type (ADT)? Write an abstract data type for linked list. [8]

10. Write an algorithm for Bubble sort. Find time complexity of the algorithm and express it using asymptotic notation. [8] 11. Sort the following numbers step by step by using Radix sort : [8] 20, 15, 21, 06, 08, 05, 29, 02, 14, 40. 12. Write an algorithm for binary search and find out its time complexity. [8] 13. Explain with one example index sequential search. [8] 14. Write a C program to implement quicksort. [8] 15. Give any two application of sorting and searching.[4] 16. Write psedo c algorithm for merge sort and determin its time Complexity.[6] 17. write psedo c algorithm to search an element using binary search and analyze its time complexity for best and worst cases.[6] 18. Write psedo C algorithm for insertion sort and determine its time complexity [6]. 19. Write the contents of list and each bucket,after each pass radix sort for the following list of numbers: 10,2,15,246,37,4,25,62,100,17. [6] 20. What is sort efficiency and sort stability?[4] 21. Compare the selection sort and inserton sort with respective to: [8] (i) Time Complexity (ii)passes(iii) Storage requirement (iv) Sort stability 22. Sort the following data in asending order using quick sort Show all passes with pivot: 56,12,84,56,28,0,-13,47,94,31 [8] 23. Write the different application of sorting methods.[6] 24. Write psedo code for binary search with recursion.[6] 25. What is bubble sort? Explain with example [4] Unit 5 1. Explain Generalized Linked List (GLL) with node structure in C. Represent the following using GLL : (a, b, c, (d, (e, f, c)), g), h, i). [10] 2. Write a function to create singly linked list which is sorted while creation. [6] 3. Represent the following polynomial equation in Generalized Linked List (GLL) :

10x4y10z3 + 4x7y10z3 + 5x7y10z3 + x3y10z2 + 8x3y10z2 + 8y10. Also give the importance of the tag field in this representation. [8] 4. Write short note on garbage collection and compaction. [4] 5. Write a function to display the singly linked list in reverse without creating new. [4] 6. Show how a two-dimensional array is stored in memory. Assume that array start at the address 4000. [4] 7. Explain how a polynomial is represented using array with one example. [5] 8. Write an algorithm for fast transpose of sparse matrix and find out its time complexity. [9] 9. Write a C program to implement polynomial using array and perform its multiplication. (Write separate functions for accepting polynomial, multiplication, display). [10] 10. What is sparse matrix? Explain with one example. [4] 11. (ii) What is address of element arr[4] [3] in the array arr of size 6 6 and type integer, when arr is represented using row major and column major representations? Assume array arr starts at the address 7000. 12. What is static memory allocation and dynamic memory allocation? [4] 13. Compare doubly linked list and circular linked list. [4] 14. Write an algorithm to delete and insert a node in doubly linked list at any position. [8] 15. What is skep list? Explain with one example. [4] 16. Draw GLL for the following expression : [4] (a, b, (c, d, (e, f), g, (h, i), ((j, k)), l), m) 17. What a C program to implement circular linked list and display the contents in reverse order. (Write separate functions for create and display) [8] 18. What do you mean by dynamic memory allocation?how is it done in c?[4] 19. Write c Function for create, insert at end,delete a given node and display list,operations on a singly linked list.[6] 20. Write a C function to concatenate two circular linked list.[6] 21. Represent the following polynomial using circular linked list: (i)12x 6-2x 5-3x + 10 (ii)3x7 + 5x 2 + 2x [4] 22. What is Doubly linked list? Explain any two application of doubly linked list.[6]

23. Write C function for the following operations by choosing appropriate linked list: (i)to search a given element in list (ii) to traverse the list from any node. 24. Represent the following polynomial using arrays: (i)x 3 + 2xy 5 - y 3 y +x (ii)5x 2-10xy-y 2-20 25. Write a short note on Storage representation of order list.[6] 26. Write Pseudo C algorithm for addition of two polynomials [8] 27. Explain with the example simple and fast transpose [8] Unit 6 1. Write a short note on Josephus problem. [4] 2. Write an ADT for stack. [4] 3. Convert the following infix expression into postfix expression by showing the contents of stack for every iteration : ((A/B Ù C) + (D * E)) (A * F)). Evaluate the postfix expression obtained for A = 9, B = 3, C = 2, D = 3, E = 17, F = 3. [10] 4. List any four applications of stack and explain any one of them. [4] 5. Explain the concept of multistack with example. [4] 6. Convert the following postfix expression to infix and prefix using stack. Show the contents of stack at every stage : abcde Evaluate given postfix expression for a = 50, b = 3, c = 4, d = 2, e = 1. [10]. 7. Sort the following numbers step by step by using Radix sort : [8] 20, 15, 21, 06, 08, 05, 29, 02, 14, 40. 8. Write an algorithm for binary search and find out its time complexity. [8] 9. Define stack.write algorithms for operation on a stack represented using array.[6] 10. Write pseudo C algorithms for operation on a stack represented using array[6] 11. Write psedo c algorithm to convert infix expression to postfix expression using linked stack.[6] 12. Write a c function to reverse a given string using stack. check a given is palindrome or not, using this function.[6]

13. Define queue.write linear queue as ADT using linked organization.[6] 14. How the circular queue solves the problem in linear queue?give the representation of circular queue using array and linked list.[6] 15. Write short note on the following: [6] (i) Queue Simulation (ii) Priority Queue 16. Write C pseudo code to insert and delete an element from singly linked list [6] 17. compare linked list with arrays with reference to the following aspects: (i) accessing any element randomly (ii) insertion and deletion of an element (iii) utilization of computer [6] 18. Discuss the application of circular singly linked list in detail[6] 19. Write comparison between sequential linked organization with linked organization [6] 20. Represent the following GLL: (i) G=((a,b)((c,d),e)) (ii)(p,q(r,s(t,u,v),w)x,u)[6] 21. Write C function that removes all duplicates element from SLL.[6]