Email : [email protected] IGNOU Friend

Course Code : CS-62 Course Title : ‘C’ Programming & Data Structure Assignment Number : BCA (2)-62/Assignment/ 2011 Maximum Marks : 25 Last Date of Submission : 30th April, 2011/30th October, 2011

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

There are three questions in this assignment. Answer all the questions. You may use illustrations and diagrams to enhance your explanations. Question 1: Write an algorithm for the implementation of a circular doubly linked list (10 Marks) Operations 1)insertion 2)forward traversal 3)reverse traversal 4)search

#include cll*hd; struct cll { private: int data; cll *next; public: cll* insert_one(int d,cll* c) { cll*NEW; NEW=new cll; NEW->data=d; NEW->next=NULL; if(c==NULL) { c=NEW; c->next=c; } else { cll*c1=c; while(c1->next!=c) c1=c1->next; c1->next=NEW; NEW->next=c; } return c; } cll* delete_one(int,cll*); void ftraverse(cll* c) { if(c==NULL) { cout<<"\nlist empty\n"; return; Page | 2 CS-62

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

} else { cll *c1=c; cout<data<<"->"; c1=c1->next; while(c1!=c) { cout<data<<"->"; c1=c1->next; } cout<<"NULL\n"; } } void rtraverse(cll* c) { if(c->next==hd) { cout<data<<"->"; return; } else rtraverse(c->next); cout<data<<"->"; } void search(int d,cll* c) { cll*c1=c; if(c==NULL) { cout<<"\nlist empty\n"; return; } else { if(c->data == d) { cout<<"found\n"; return ; } while(c->next !=c1) { if(c->data==d) { cout<<"found\n"; return ; } c=c->next; } Page | 3 If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

CS-62

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

if(c->data ==d) { cout<<"found\n"; return ; } cout<<" search unsuccess ful \n"; } } void function() { cout<<"******************************************\n"; cout<<"program to implement a circular linked list \n"; cout<<"******************************************\n"; cll * head; head=NULL; cout<<"\n\nMENU :\n"; cout<<"1)insertion\n" <<"2forward traversal\n" <<"3)reverse traversal\n" <<"4)search\n" <<"5)exit\n\n"; cout<<"Enter your option :"; int opt; cin>>opt; int d; while(opt!=5) { switch(opt) { case 1: cout<<"Enter data to the node :"; cin>>d; head=insert_one(d,head); cout<<"inserted\n"; break; case 2: cout<<"The forward traversal is :\n"; ftraverse(head); break; case 3: cout<<"The reverse traversal is :\n"; hd=head; rtraverse(head); cout<<"NULL\n"; break; case 4: Page | 4 CS-62

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

cout<<"Enter the element to be searched :"; int d; cin>>d; search(d,head); break; case 5: break; default: cout<<"invalid option"; break; } cout<<"\n\nMENU :\n"; cout<<"1)insertion\n" <<"2)forward traversal\n" <<"3)reverse traversal\n" <<"4)search\n" <<"5)exit\n\n"; cout<<"Enter your option :"; cin>>opt; } } }; void main() { cll list; list.function(); } Question 2: What are the advantages of Arrays and Pointers? What is the basis for selection of Arrays or Pointers as data structure in a program. (5 Marks) POINTERS Pointers are generally useful in the context where we need a continuous memory allocation. Using pointers dynamic allocation of memory is achieved pointers basically hold the address of a variable. they are mainly used as function parameters to pass values of parameters as references rather than values

ARRAYS You can use one name for similar objects and save then with the same name but different indexes. Arrays are very useful when you are working with sequences of the same kind of data (similar to the first point but has a different meaning). Arrays use reference type and so.

The principal benefit of a linked list (using pointer) over a conventional array is that the list elements can easily be added or removed without reallocation or reorganization of the entire structure because the data items need not be stored contiguously in memory or on disk. Linked lists (pointer) allow insertion and removal of nodes at any point in the list, and can do so with a constant number of Page | 5 CS-62

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

operations if the link previous to the link being added or removed is maintained during list traversal. On the other hand, simple linked lists by themselves do not allow random access to the data other than the first node's data, or any form of efficient indexing. Thus, many basic operations — such as obtaining the last node of the list (assuming that the last node is not maintained as separate node reference in the list structure), or finding a node that contains a given datum, or locating the place where a new node should be inserted — may require scanning most or all of the list elements. A pointer can refer to an individual item or to an array of items. In fact, an array is just a way of creating both a list of items and a pointer to that list's first item in one declaration. The array and pointer concepts are more or less completely interchangeable in C. This means that subscripts can be used with pointers, as if they were arrays held at the address of the pointer. As C does no array bound checking, this is completely unsafe. You may assign the address of a simple int variable to a pointer to int and than access locations following it as if they belonged to an array of ints, as follows. void main() { int i, * ip; ip = & i; ip[0] = 3; ip[1] = 2; ip[2] = 1; } On the other hand, an array can be used as if it was a pointer. We have seen that arrays are always passed by reference, even though no & is written, and this is why. The only difference is that the address of an array cannot be changed by assignment. Thus, the following would not be allowed: void main() { int i, ia[]; ia = &i; } Page | 6

CS-62

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Email : [email protected] IGNOU Friend

Question 3: What is a row major order? What is a column major order? How will you find the location of an element of an array , if the array is stored using row major order? Answer the question, if the array is stored in column major order. (10 Marks) Lets now see how the data represented in an array is actually stored in the memory cells of the machine. Because computer memory is linear, a one-dimensional array can be mapped on to the memory cells in a rther straight forward manner. Sotrage for element A[I+1] will be adjacent to storage for element A[I] for I=0,1,2,… N-1. To find the actual address of an element one merely needs to subtract one from the position of the desired entry and then add the result to the address of the first cell in the sequence. Let us see it through an example. Consider an array A of 26 elements. We require to find the addressof A[4]. If the first cell in the sequence A[0] A[1],A[2],….A[25]. Was at address 16, then A[4] would be located at 16+4 = 20, as shown in Firgure. We assume that the size of each elemtn stored is one unit. Memory Cells

Full Answer available soon…

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]

Course Code : CS-62 Course Title : 'C' Programming & Data ...

If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]. Course Code : CS-62. Course Title : 'C' Programming ...

43KB Sizes 3 Downloads 320 Views

Recommend Documents

Course Contents Category of Course Course Title Course Code ...
Course Contents. Category of. Course. Course Title. Course Code Credits – 6C. Theory Papers. (ES). L T P ... Fluid Mechanics and Machinery- Agrawal, TMH. 3.

Course Code : CS- 74 Course Title : Introduction to Internet ...
Oct 30, 2011 - IGNOU Friend. If you have any query just email us at www.ignoufriend.blogspot.com Email : [email protected]. Course Code : CS- 74.

Course Information Form Course title: Essay Writing Course Stage ...
Course Information Form. Course title: Essay Writing. Course Stage: Junior Students ... An update course-book (2006) in essay writing is adopted as a text-book. It consists of a number of chapters that provide ... to-date American course book) by: D.

MCS-042 Course Title : DATA COMMUNICATION AND COMPUTER ...
Course Code. : MCS-042 ... DATA COMMUNICATION AND COMPUTER NETWORK .... Only four bits of host suffix are needed to represent all possible host.

continuing education unit participant evaluation course title
CEU4EVAL.PM4. (Name of Sponsoring Organization). CONTINUING EDUCATION UNIT. PARTICIPANT EVALUATION. COURSE TITLE: ...

continuing education unit participant evaluation course title
3. The course content met the course objectives: ______. 4. The training aids/handouts used were beneficial: ______. 5. My overall rating of the course was:.

Course Name: Data Structure
To be able to understand the concepts of Database Programming, using JDBC. ... Integrating Servlets and JSP in a Web Application (MVC Architecture for Web ...

pdf-1494\sas-programming-2-data-manipulation-techniques-course ...
Connect more apps... Try one of the apps below to open or edit this item. pdf-1494\sas-programming-2-data-manipulation-techniques-course-notes-by-sas.pdf.

Course Name: Data Structure - WordPress.com
To be able to create web pages using HTML and Javascript. • To be able to ... 2. Servlet Basics, Basic Servlet structure, Servlets Generating text/html content ...

(Tutor Marked) Programme Code: DCCN Course Code: BNS
Q1. a). Define Intra abdominal compartment syndrome. b). Explain its etiology and pathophysiology. c). Describe its nursing management. 2+3+5=15. Q2 a). Define Open Heart Surgery. b). Classify Open Heart Surgeries. c). Discuss Nursing Care plan of pa

MCS-013 Course Title : Discrete Mathematics ...
is a tautology or not. Ans : Tautology : A compound proposition that is true for all possible truth values of the simple propositions involved in it is called a ...

Course Outcome - Web Programming and Networking Lab.pdf ...
Course Outcome - Web Programming and Networking Lab.pdf. Course Outcome - Web Programming and Networking Lab.pdf. Open. Extract. Open with. Sign In.

Parallel Programming Course Threading Building ...
Apr 6, 2014 - Library provides predefined ranges : ○ blocked_range, blocked_range2d, blocked_range3d. You can define yours, .... we will show you the Lambda way when it can be used. Lambda functions are part of the C++11 standard, you might need to

Course Handout - Web Programming and Services Theory.pdf ...
Course Handout - Web Programming and Services Theory.pdf. Course Handout - Web Programming and Services Theory.pdf. Open. Extract. Open with. Sign In.

General Information Course Title : Real Projects for ...
Overview. The Bureau of Labor Statistics (BLS) predicts at least 500,000 new high-paying jobs in IT/software development over the next 3-4 years, even in the face of the current economic crisis. (The number of new job openings will increase even fast

Finding Data Races in C++ Code
If you've got some multi-threaded code, you may have data races in it. Data races ... Valgrind is a binary translation framework which has other useful tools such.

Revised Data Use course materials
Teamwork analysis of the focusing question data .... Key question data analysis ... Our first grade students' math word problems solving skills are at a low level.

course information: instructor course description ...
Occasionally, pop-up quizzes will be given in class. This serves both as a tool to check your current state of knowledge. The quizzes will test material that has been covered in class and homework. There will be 4 quizzes, and the lowest two quiz gra

The time course oforthographic and phonological code ...
associative, and grammatical context effects with identified and uniden- tified primes. Language & Speech, 33, 1-18. LUKATELA, G., & TURVEY, M. T. (l990a).