Solution: The examples of stack application are reverse a string, post fix evaluation, infix to postfix conversion.
|
|
- Randall Jefferson
- 5 years ago
- Views:
Transcription
1 1. What is the full form of LIFO? The full form of LIFO is Last In First Out. 2. Give some examples for stack application. The examples of stack application are reverse a string, post fix evaluation, infix to postfix conversion. 3. Write an algorithm to convert infix to postfix. Algorithm to Convert Infix Expression to Postfix Form. The following algorithm transforms the infix expression X into its equivalent postfix expression Y. The algorithm uses a stack to temporarily hold operators and the left parentheses. The postfix expression Y will be constructed from left to right using operands from X and the operators which are removed from STACK. We begin by pushing a left parenthesis onto STACK and adding a right parenthesis at the end of X. The algorithm is completed when the STACK is empty. ALGORITHM-Infix to Postfix Conversion using Stack. Suppose X is an arithmetic expression written in infix notation. This algorithm finds the equivalent postfix expression Y. 1. Push "("onto STACK, and add ")" to the end of X. 2. Scan X from left to right and REPEAT Steps 3 to 6 for each element of X. UNTIL the STACK is empty: 3. If an operand is encountered, add it to Y. 4. If a left parenthesis is encountered, push it onto STACK. 5. If an operator is encountered, then: (a) Repeatedly pop from STACK and add to Y each operator (on the top of STACK) which has the same precedence as or a higher precedence than the operator. (b) Add operator to STACK. /* End of if structure */ 6. If a right parenthesis is encountered, then: (a) Repeatedly pop from STACK and add to Y each operator (on the top of STACK) until a left parenthesis is encountered. 1
2 (b) Remove the left parenthesis. [Do not add the left parenthesis to Y]. /* End of the If structure */ /* End of step 2 loop */ 7. END. 4. Write an algorithm to insert an element into a stack as an array and for linked stack. ALGORITHM- Pushing in Stack-Array /* Assuming that array-stack can hold maximum N elements 1. top = -1 /* Initialize stack with invalid subscript value to show that it is empty. Legal subscript values are 0 (N-1)*/ 2. Read item // Item, which is to be pushed 3. If (top==n-1)then /* if top is at end of stack-array */ 4. Print "Overflow!!" 5. Else 6. top=top+1 /* Increment top to move to next empty position to hold new item */ 7. Stack[top] = Item 8. END. ALGORITHM-Pushing in Linked -Stack /* Get new node for the ITEM to be pushed */ 1. NEWPTR = new Node 2. NEWPTR -> INFO = ITEM ; NEWPTR - > LINK = NULL /*Add new node at the top */ 3. If TOP = NULL then /* stack is empty */ 2
3 4. TOP = NEWPTR 5. else 6. NEWPTR -> LINK=TOP 7. TOP = NEWPTR // of step 3 8. END. 5. Write an algorithm to insert element into a queue. ALGORITHM - Insertion in Array Queue /* given Rear and Front are pointers to the rear and front of a queueu QUEUE, with size N and an element ITEM is to be inserted into the queue*/ 1. If rear = NULL Then // sets the pointers to 0 because the first element is inserted in the queue 2. Rear = front =0 3. QUEUE[0] = ITEM 4. Else if rear = N-1 Then //checks for overflow 5. Print "QUEUE FULL, OVERFLOW!!" 6. Else 7. QUEUE [rear+1] = ITEM //increments rear pointer and inserts the element 8. rear = rear END. 6. Write an algorithm to delete an element from a queue 3
4 ALGORITHM-Deletion in Array-Queue /* given Rear and Front are pointers to the rear and front of a queue QUEUE, with size N and ITEM is a temporary variable*/ 1. If front = NULL Then // check whether queue is underflow 2. print "Queue Empty" 3. Else 4. ITEM = QUEUE[front] // moves the first element to the temporary variable 5. if front = rear Then //checks whether that is the last element in the queue 6. front = rear = NULL 7. Else 8. front = front + 1 // increments the front pointer 7. Write an algorithm to delete an element from a stack as linked. ALGORITHM-Popping from a Linked-Stack 1. If TOP = NULL then 2. Print "Stack Empty, UNDERFLOW!!" 3. Else 4. Print TOP -> INFO 5. TOP =TOP -> LINK 6. END. 4
5 8. Change the following from infix to post fix (A+B)*C+D/E-F AB+C*DE/+F- 9. Change the following from infix to post fix A+B-D/X AND (X+Y)/(Z*Y)-R AB+DX/- AND XY+ZY*/R- 10. Change the following from infix to post fix+ ((B+C)+(D+E)*F)/G ABC+DE+F*+G/+ 11. Change the following from infix to post fix A*(B+(C+D)*(E+F)/G)*H ABCD+EF+*G/+*H* 12. Write an algorithm to implement PUSH and POP operation on a stack. /* Assuming that array-stack can hold maximum N elements 1. top = -1 /* Initialize stack with invalid subscript value to show that it is empty. Legal subscript values are 0 (N-1)*/ 2. Read item // Item, which is to be pushed 3. If (top==n-1)then /* if top is at end of stack-array */ 4. Print "Overflow!!" 5. Else 6. top=top+1 /* Increment top to move to next empty position to hold new item */ 7. Stack[top] = Item 8. END. 5
6 ALGORITHM- Popping from Array-Stack /* Firstly, check for underflow condition */ 1. If top==-1 then 2. Print "Underflow!!" 3. Exit from program 4. Else 5. Print stack(top) 6. top = top +1 /* top moved, so that the top most element becomes */ /* inaccessible which is a sort of a deletion */ 7. END. 13. Write the various applications of stack in detail. Evaluation of a postfix Expression As postfix expression is without parenthesis and can be evaluated as two operands and an operator at a time, this becomes easier for the compiler and the computer to handle. Evaluation rule of a postfix expression states: While reading the expression from left to right, push the element in the stack if it is an operand; pop the two operands from the stack, if the element is an operator (except NOT operator). In case of NOT operators, pop one operand from the stack and then evaluate it (two operands and an operator). Push back the result of the evaluation. Repeat it till the end of the expression. For a binary operator, two operands, one popped from stack and the for a binary operator, one operand is popped. Then, the result is calculated using operand(s) and the operator, and pushed back into the stack. Polish Strings Another application of stacks is in the conversion of arithmetic expression in high-level programming languages into machine readable form. As our computer system can only understand and work on a binary language, it assumes that an arithmetic operation can take place in two operands only, e.g., A+B, CXD, D/A, etc. But in our usual form - an arithmetic expression may consist of more than one operators and two operands, e.g., (A+B) X C (D/(J+D)). These complex arithmetic operations can be 6
7 converted into polish strings using stacks which can be executed in two operands and an operator form. Polish string, named after a polish mathematician, Jan Lukasiewicz, refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after its operands (postfix notation) in contrast to the usual form where operator is placed in-between the operands (infix notation). The following table shows three types of notations: 14. Write algorithms to implement operations on a circular queue. Queues can be used in several forms and ways, depending upon the requirements of the program. Two popular variations of queues are circular queues and dequeues (double ended queues). Circular Queues are the queues implemented in a circular form rather than a straight line. Circular queues overcome the problem of unutilized space in linear queues implemented as arrays (if shifting is not done to avoid the problem of unutilized space, but shifting as such makes it complex to implement). We saw that queues don t effectively use the memory. To overcome this, we have designed the circular queues. It uses array as a circular structure. If the rear point of the queue reaches the end of the array, we can add a new element at the beginning of the array if it is vacant. One should keep in mind that it does not spoil the operations of a queue. This is achieved by using the front and rear pointers effectively. front = N-2 N- 1 rear = N (a) Queue at any arbitrary point of line front = N-2 N- 1 rear = N (b) One element inserted front = N-2 N- 1 rear = N (c) One element deleted front = N-2 N- 1 rear = (d) One more element inserted [The circular queue considers itself contiguous at opposite ends, that is why, if space is there in the beginning, the rear shifts back to beginning after reaching the maximum possible index-number.] 7
8 Fig. (a) operations in a circular queue implemented as an array. Fig. (b) A Circular Queue. Deque (double-ended queues) are the refined queues in which elements can be added or removed at either end but not in the middle. There are two variation of a deque an input restricted deque and an output restricted deque. An input restricted deque is a deque which allows insertions at only one end but allows deletions at both ends of the list. An output restricted deque is a deque which allows deletion at only one end of the list but allows insertions at both ends of the list. Algorithm-Insertion in a Circular Queue /* Assuming that the circular queues is stored in QU with size N. Check if Queue already filled or not */ 1. If (FRONT = AND REAR = N- 1) or (FRONT = REAR +1) Then Write " Overflow!!" Else 2. If FRONT = NULL Then [QU is initially empty] Set FRONT = 0 REAR = 0 8
9 3. Else IF REAR = N-1 Then Set REAR = 0 Else 4. Set REAR = REAR +1 //End of if 5. Set QU [REAR] = I_ITEM // (to insert the new item I_ITEM 6. END. Algorithm-Deletion in a circular Queue. /* Assuming that the queue is stored in as array QU with size N. This algorithm will delete an element from the queue and assign it to D-ITEM. */ /* Check if QU is already empty or not? */ 1. If FRONT = NULL Then Write " Underflow!!" Return Else 2. Set D_ITEM = QU[FRONT] /* Now Make FRONT point to the next element in the queue */ 3. If FRONT = REAR Then FRONT = NULL REAR = NULL 9
10 4. Else If FRONT = N-1 Then FRONT = 0 Else 5. FRONT = FRONT END. 15. What are the various operations on a linked list? When manipulating linked lists in-place, care must be taken to not use values that you have invalidated in previous assignments. This makes algorithms for inserting or deleting linked list nodes which are somewhat subtle. This section gives pseudo code for adding or removing nodes from singly, doubly, and circularly linked lists in-place. Throughout, we will use null to refer to an end-oflist marker which may be implemented in a number of ways. Traversal Our node data structure will have two fields. We also keep a variable firstnode which always points to the first node in the list, or is null for an empty list. record Node data // The data being stored in the node next // A reference to the next node, null for last node record List Node firstnode // points to first node of list; null for empty list Traversal of a singly-linked list is simple, beginning at the first node and following each next link until we come to the end: node := list.firstnode while node not null (do something with node.data) node := node.next 10
11 Insertion The following code inserts a node after an existing node in a singly linked list. The diagram shows how it works. Inserting a node before an existing one cannot be done; instead, you have to locate it while keeping track of the previous node. function insertafter(node node, Node newnode) // insert newnode after node newnode.next := node.next node.next := newnode Inserting at the beginning of the list requires a separate function. This requires updating firstnode. function insertbeginning(list list, Node newnode) // insert node before current first node newnode.next := list.firstnode list.firstnode := newnode Deletion Similarly, we have functions for removing the node after a given node, and for removing a node from the beginning of the list. The diagram demonstrates the former. To find and remove a particular node, one must again keep track of the previous element. 11
12 function removeafter(node node) // remove node past this one obsoletenode := node.next node.next := node.next.next destroy obsoletenode function removebeginning(list list) // remove first node obsoletenode := list.firstnode list.firstnode := list.firstnode.next // point past deleted node destroy obsoletenode Notice that removebeginning() sets list.firstnode to null when removing the last node in the list. Since we can't iterate backwards, efficient "insertbefore" or "removebefore" operations are not possible. Appending one linked list to another can be inefficient unless a reference to the tail is kept as part of the List structure, because we must traverse the entire first list in order to find the tail, and then append the second list to this. Thus, if two linearly-linked lists are each of length n, list appending has asymptotic time complexity of O(n). In the Lisp family of languages, list appending is provided by the append procedure. Many of the special cases of linked list operations can be eliminated by including a dummy element at the front of the list. This ensures that there are no special cases for the beginning of the list and renders both insertbeginning() and removebeginning() unnecessary. In this case, the first useful data in the list will be found at list.firstnode.next. 16. Differentiate singly linked list vs array. Array Linked list Elements can be inserted into While an array will eventually linked lists indefinitely. either fill up or need to be esized, an expensive operation that may not even be possible if memory is fragmented. Memory savings can be achieved. Similarly, an array from which many elements are removed may become wastefully mpty or need to be made smaller. While linked lists allow only Arrays allow random access. sequential access to elements. Singly-linked lists, in fact, can only Arrays can be traversed in be traversed in one direction. both the directions. 12
13 A disadvantage of linked lists is the extra storage needed for references, which often makes them impractical for lists of small data items such as characters or Boolean values. Bad Sequential access on arrays is also faster than on linked lists on many machines due to locality of reference and data cache. 17. What are the trade-offs of a linked list. As with most choices in computer programming and design, no method is well suited to all circumstances. A linked list data structure might work well in one case but causes problems in another. This is a list of some of the common trade-offs involving linked list structures. In general, if you have a dynamic collection, where elements are frequently being added and deleted, and the location of new elements added to the list is significant, then benefits of a linked list increase. 18. How is a linked list represented in memory. Let list be implemented in memory in the simplest form of implementation. LIST requires two linear arrays one called as INFO array for INFO storage and the other known as LINK array for the next pointer. 19. Write a short note on static and dynamic memory allocation. Static memory allocation This memory allocation method reserves a fixed amount before the actual processing takes place. The number of elements to be stored is predefined. Arrays the memory is allocated using this technique. Dynamic memory allocation This memory allocation method allows allocation of memory during the program execution itself, as and when required. This technique of memory allocation is called as dynamic memory allocation. This facilitates release of memory. (Data structures like linked lists and tree use this technique. Please rephrase the sentence!) 20. How do you traverse a linked list? 13
14 Our node data structure will have two fields. We also keep a variable firstnode which always points to the first node in the list, or is null for an empty list. record Node data next // The data being stored in the node // A reference to the next node, null for last node record List Node firstnode // points to first node of list; null for empty list Traversal of a singly-linked list is simple, beginning at the first node and following each next link until we come to the end: node := list.firstnode while node not null (do something with node.data) node := node.next 21. What is the procedure to insert an element in a linked list? The following code inserts a node after an existing node in a singly linked list. The diagram shows how it works. Inserting a node before an existing one cannot be done; instead, you have to locate it while keeping track of the previous node. function insertafter(node node, Node newnode) // insert newnode after node 14
15 newnode.next := node.next node.next := newnode Inserting at the beginning of the list requires a separate function. This requires updating the firstnode. function insertbeginning(list list, Node newnode) // insert node before current first node newnode.next := list.firstnode list.firstnode := newnode 22. Write short notes on polish strings. Another application of stacks is in the conversion of arithmetic expression in high-level programming languages into machine readable form. As our computer system can only understand and work on a binary language, it assumes that an arithmetic operation can take place in two operands only, e.g. A+B, CXD, D/A, etc. But in our usual form an arithmetic expression may consist of more than one operators and two operands, e.g., (A+B) X C (D/(J+D)). These complex arithmetic operations can be converted into polish strings using stacks which can be executed in two operands and an operator form. The polish string, named after a polish mathematician, Jan Lukasiewicz, refers to the notation in which the operator symbol is placed either before its operands (prefix notation) or after its operands (postfix notation) in contrast to the usual form where operator is placed in-between the operands (infix notation). The following table shows the three types of notations: Notation Infix Prefix Postfix Example A+B +AB AB+ 23. State the advantages of postfix over infix expression. An infix expression is difficult for the machine to know and keep track of precedence of operators. On the other hand, a postfix expression itself determines the precedence of operators (as the placement of operators in a postfix expression depends upon its precedence). Therefore, for the machine it is easier to carry out a postfix expression than an infix expression. 24. Write a short note on queue. A queue is an ordered group of elements in which new elements are added at one end and the elements are removed at the other end. The insertion end is called the rear and the deletion end is called the front. 15
16 Example: Line of viewers in a theatre s ticket counter. New person will join at the end while people who got their tickets will leave the counter at the front. This works on a first-come first-served basis (FCFS). The main thing is that it performs insertion at one end and deletion at the other end. Logically, a queue is a FIFO structure and physically it can be implemented either as an array or as a linked list. Whatever way a queue is implemented, insertions take place at the "rear" end and deletions at the "front" end. 16
Linked lists * Nguyen Viet Ha, Truong Ninh Thuan, Vu Quang Dung Linked lists
OpenStax-CNX module: m29464 1 Linked lists * Nguyen Viet Ha, Truong Ninh Thuan, Vu Quang Dung This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 3.0 1 2.
More informationLINKED IMPLEMENTATION OF LIST
LINKED IMPLEMENTATION OF LIST Mohd. Saeed 1, Mayank Gulati 2 1,2 Department of Information Technology, Shri Ramdeo Baba K.N. Engineering College, Nagpur (India) ABSTRACT This paper address about the link
More informationContent: Learning Objectives
1 BLOOM PUBLIC CHOOL Vasant Kunj, New Delhi Lesson Plan Class: XII ubject: Computer cience Month : July No of s: 21 Chapter:Data structure: Linked List TTT: 8 WT: 12 Content: Learning Objectives At the
More informationLINKED LISTS. Abhishek Vashishtha,Deepak Goswami Student, Department of Information, Dronacharya College Of Engineering, Gurgoan, Haryana, India
LINKED LISTS Abhishek Vashishtha,Deepak Goswami Student, Department of Information, Dronacharya College Of Engineering, Gurgoan, Haryana, India Abstract- In this paper we are going to throw light on linked
More informationDEEPIKA KAMBOJ UNIT 2. What is Stack?
What is Stack? UNIT 2 Stack is an important data structure which stores its elements in an ordered manner. You must have seen a pile of plates where one plate is placed on top of another. Now, when you
More informationEC8393FUNDAMENTALS OF DATA STRUCTURES IN C Unit 3
UNIT 3 LINEAR DATA STRUCTURES 1. Define Data Structures Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between
More informationData Structures. Chapter 06. 3/10/2016 Md. Golam Moazzam, Dept. of CSE, JU
Data Structures Chapter 06 1 Stacks A stack is a list of elements in which an element may be inserted or deleted only at one end, called the top of the stack. This means that elements are removed from
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours
TED (10)-3071 Reg. No.. (REVISION-2010) (Maximum marks: 100) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- MARCH, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours PART
More informationDOWNLOAD PDF LINKED LIST PROGRAMS IN DATA STRUCTURE
Chapter 1 : What is an application of linear linked list data structures? - Quora A linked list is a linear data structure, in which the elements are not stored at contiguous memory locations. The elements
More informationSome Applications of Stack. Spring Semester 2007 Programming and Data Structure 1
Some Applications of Stack Spring Semester 2007 Programming and Data Structure 1 Arithmetic Expressions Polish Notation Spring Semester 2007 Programming and Data Structure 2 What is Polish Notation? Conventionally,
More information1 P age DS & OOPS / UNIT II
UNIT II Stacks: Definition operations - applications of stack. Queues: Definition - operations Priority queues - De que Applications of queue. Linked List: Singly Linked List, Doubly Linked List, Circular
More informationThe Bucharest University of Economic Studies. Data Structures. ADTs-Abstract Data Types Stacks and Queues
The Bucharest University of Economic Studies Data Structures ADTs-Abstract Data Types Stacks and Queues Agenda Definition Graphical representation Internal interpretation Characteristics Operations Implementations
More informationDATA STRUCTURE UNIT I
DATA STRUCTURE UNIT I 1. What is Data Structure? A data structure is a mathematical or logical way of organizing data in the memory that consider not only the items stored but also the relationship to
More informationLecture Data Structure Stack
Lecture Data Structure Stack 1.A stack :-is an abstract Data Type (ADT), commonly used in most programming languages. It is named stack as it behaves like a real-world stack, for example a deck of cards
More informationFORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE
TED (10)-3071 Reg. No.. (REVISION-2010) Signature. FORTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLIGY- OCTOBER, 2012 DATA STRUCTURE (Common to CT and IF) [Time: 3 hours (Maximum marks: 100)
More informationFormal Languages and Automata Theory, SS Project (due Week 14)
Formal Languages and Automata Theory, SS 2018. Project (due Week 14) 1 Preliminaries The objective is to implement an algorithm for the evaluation of an arithmetic expression. As input, we have a string
More informationLists, Stacks, and Queues. (Lists, Stacks, and Queues ) Data Structures and Programming Spring / 50
Lists, Stacks, and Queues (Lists, Stacks, and Queues ) Data Structures and Programming Spring 2016 1 / 50 Abstract Data Types (ADT) Data type a set of objects + a set of operations Example: integer set
More informationTypes of Data Structures
DATA STRUCTURES material prepared by: MUKESH BOHRA Follow me on FB : http://www.facebook.com/mukesh.sirji4u The logical or mathematical model of data is called a data structure. In other words, a data
More informationDATA STRUCUTRES. A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.
DATA STRUCUTRES A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently. An algorithm, which is a finite sequence of instructions, each of which
More informationThe time and space are the two measure for efficiency of an algorithm.
There are basically six operations: 5. Sorting: Arranging the elements of list in an order (either ascending or descending). 6. Merging: combining the two list into one list. Algorithm: The time and space
More informationObjective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113)
Objective Questions for Online Practical Exams under CBCS Scheme Subject: Data Structure-I (CS-113) 1. The number of interchanges required to sort 5, 1, 6, 2 4 in ascending order using Bubble Sort (A)
More informationSample Question Paper
Scheme - I Sample Question Paper Marks : 70 Time: 3 Hrs. Q.1) Attempt any FIVE of the following. 10 Marks a. Write any four applications of data structure. b. Sketch the diagram of circular queue. c. State
More informationSTACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:
STACKS A stack is a linear data structure for collection of items, with the restriction that items can be added one at a time and can only be removed in the reverse order in which they were added. The
More informationCS W3134: Data Structures in Java
CS W3134: Data Structures in Java Lecture #10: Stacks, queues, linked lists 10/7/04 Janak J Parekh HW#2 questions? Administrivia Finish queues Stack/queue example Agenda 1 Circular queue: miscellany Having
More informationinfix expressions (review)
Outline infix, prefix, and postfix expressions queues queue interface queue applications queue implementation: array queue queue implementation: linked queue application of queues and stacks: data structure
More informationPostfix (and prefix) notation
Postfix (and prefix) notation Also called reverse Polish reversed form of notation devised by mathematician named Jan Łukasiewicz (so really lü-kä-sha-vech notation) Infix notation is: operand operator
More informationIntroduction to Data Structure
Introduction to Data Structure Introduction to Data Structure Computer is an electronic machine which is used for data processing and manipulation. When programmer collects such type of data for processing,
More informationR10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May
www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the
More informationSTACKS AND QUEUES. Problem Solving with Computers-II
STACKS AND QUEUES Problem Solving with Computers-II 2 Stacks container class available in the C++ STL Container class that uses the Last In First Out (LIFO) principle Methods i. push() ii. iii. iv. pop()
More information09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION
DATA STRUCTURES AND ALGORITHMS 09 STACK APPLICATION REVERSE POLISH NOTATION IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD WWW.IMRANIHSAN.COM LECTURES ADAPTED FROM: DANIEL KANE, NEIL RHODES
More informationThe Stack and Queue Types
The Stack and Queue Types Hartmut Kaiser hkaiser@cct.lsu.edu http://www.cct.lsu.edu/ hkaiser/fall_2012/csc1254.html 2 Programming Principle of the Day Do the simplest thing that could possibly work A good
More informationUNIT-II. Part-2: CENTRAL PROCESSING UNIT
Page1 UNIT-II Part-2: CENTRAL PROCESSING UNIT Stack Organization Instruction Formats Addressing Modes Data Transfer And Manipulation Program Control Reduced Instruction Set Computer (RISC) Introduction:
More informationIntroduction. Problem Solving on Computer. Data Structures (collection of data and relationships) Algorithms
Introduction Problem Solving on Computer Data Structures (collection of data and relationships) Algorithms 1 Objective of Data Structures Two Goals: 1) Identify and develop useful high-level data types
More informationADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 )
ADVANCED DATA STRUCTURES USING C++ ( MT-CSE-110 ) Unit - 2 By: Gurpreet Singh Dean Academics & H.O.D. (C.S.E. / I.T.) Yamuna Institute of Engineering & Technology, Gadholi What is a Stack? A stack is a
More informationInsert. SEMCOM Page 1 of 11
CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US02CBCA01 (Advanced C Programming and Introduction to Data Structures) *UNIT 4 (Some More Data structures
More informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad - 500 043 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name Course Code Class Branch DATA STRUCTURES ACS002 B. Tech
More informationPA3 Design Specification
PA3 Teaching Data Structure 1. System Description The Data Structure Web application is written in JavaScript and HTML5. It has been divided into 9 pages: Singly linked page, Stack page, Postfix expression
More informationProgramming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur
Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture 07 Stack and Its Applications Welcome to module 5 of Programming
More informationCSE 230 Intermediate Programming in C and C++
CSE 230 Intermediate Programming in C and C++ Structures and List Processing Fall 2017 Stony Brook University Instructor: Shebuti Rayana http://www3.cs.stonybrook.edu/~cse230/ Self-referential Structure
More informationDATA STRUCTURES AND ALGORITHMS
LECTURE 8 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 7... ADT Queue ADT Matrix ADT List ADT Stack Today ADT Queue 1 ADT Queue 2 3 4 Note ADT Queue We will not
More informationAlgorithms and Data Structures
Algorithms and Data Structures PD Dr. rer. nat. habil. Ralf Peter Mundani Computation in Engineering / BGU Scientific Computing in Computer Science / INF Summer Term 2018 Part 2: Data Structures PD Dr.
More informationStacks. Chapter 5. Copyright 2012 by Pearson Education, Inc. All rights reserved
Stacks Chapter 5 Contents Specifications of the ADT Stack Using a Stack to Process Algebraic Expressions A Problem Solved: Checking for Balanced Delimiters in an Infix Algebraic Expression A Problem Solved:
More informationAshish Gupta, Data JUET, Guna
Categories of data structures Data structures are categories in two classes 1. Linear data structure: - organized into sequential fashion - elements are attached one after another - easy to implement because
More informationCHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar
CHARUTAR VIDYA MANDAL S SEMCOM Vallabh Vidyanagar Faculty Name: Ami D. Trivedi Class: FYBCA Subject: US02CBCA01 (Advanced C Programming and Introduction to Data Structures) *UNIT 3 (Introduction to Data
More informationStacks and Queues. Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms
Stacks and Queues Chris Kiekintveld CS 2401 (Fall 2010) Elementary Data Structures and Algorithms Two New ADTs Define two new abstract data types Both are restricted lists Can be implemented using arrays
More informationStacks (Section 2) By: Pramod Parajuli, Department of Computer Science, St. Xavier s College, Nepal.
(Section 2) Linked list implementation of stack Typical Application of stacks Evaluation of expressions (infix, postfix, prefix) References and further details By: Pramod Parajuli, Department of Computer
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Stack Operations on a stack Representing stacks Converting an expression
More information12 Abstract Data Types
12 Abstract Data Types 12.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: Define the concept of an abstract data type (ADT). Define
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More informationStack Abstract Data Type
Stacks Chapter 5 Chapter Objectives To learn about the stack data type and how to use its four methods: push, pop, peek, and empty To understand how Java implements a stack To learn how to implement a
More informationMID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct.
MID TERM MEGA FILE SOLVED BY VU HELPER Which one of the following statement is NOT correct. In linked list the elements are necessarily to be contiguous In linked list the elements may locate at far positions
More informationa) State the need of data structure. Write the operations performed using data structures.
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More information3. Fundamental Data Structures
3. Fundamental Data Structures CH08-320201: Algorithms and Data Structures 233 Data Structures Definition (recall): A data structure is a way to store and organize data in order to facilitate access and
More informationLIFO : Last In First Out
Introduction Stack is an ordered list in which all insertions and deletions are made at one end, called the top. Stack is a data structure that is particularly useful in applications involving reversing.
More informationInformation Science 2
Information Science 2 - Basic Data Structures- Week 02 College of Information Science and Engineering Ritsumeikan University Today s class outline l Basic data structures: Definitions and implementation
More informationLecture 4 Stack and Queue
Lecture 4 Stack and Queue Bo Tang @ SUSTech, Spring 2018 Our Roadmap Stack Queue Stack vs. Queue 2 Stack A stack is a sequence in which: Items can be added and removed only at one end (the top) You can
More informationTop of the Stack. Stack ADT
Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that
More informationTop of the Stack. Stack ADT
Module 3: Stack ADT Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Stack ADT Features (Logical View) A List that
More informationPrepared by Mrs.D.Maladhy (AP/IT/RGCET) Page 1
Basics : Abstract Data Type(ADT) introduction to data structures representation - implementation Stack and list: representing stack implementation application balancing symbols conversion of infix to postfix
More information17CS33:Data Structures Using C QUESTION BANK
17CS33:Data Structures Using C QUESTION BANK REVIEW OF STRUCTURES AND POINTERS, INTRODUCTION TO SPECIAL FEATURES OF C Learn : Usage of structures, unions - a conventional tool for handling a group of logically
More informationStack Applications. Lecture 27 Sections Robb T. Koether. Hampden-Sydney College. Wed, Mar 29, 2017
Stack Applications Lecture 27 Sections 18.7-18.8 Robb T. Koether Hampden-Sydney College Wed, Mar 29, 2017 Robb T. Koether Hampden-Sydney College) Stack Applications Wed, Mar 29, 2017 1 / 27 1 Function
More informationStacks, Queues (cont d)
Stacks, Queues (cont d) CSE 2011 Winter 2007 February 1, 2007 1 The Adapter Pattern Using methods of one class to implement methods of another class Example: using List to implement Stack and Queue 2 1
More informationData Structures. Outline. Introduction Linked Lists Stacks Queues Trees Deitel & Associates, Inc. All rights reserved.
Data Structures Outline Introduction Linked Lists Stacks Queues Trees Introduction dynamic data structures - grow and shrink during execution Linked lists - insertions and removals made anywhere Stacks
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationAdvanced Linked Lists. Doubly Linked Lists Circular Linked Lists Multi- Linked Lists
Advanced Linked Lists Doubly Linked Lists Circular Linked Lists Multi- Linked Lists Review The singly linked list: consists of nodes linked in a single direction. access and traversals begin with the first
More informationCS 206 Introduction to Computer Science II
CS 206 Introduction to Computer Science II 07 / 26 / 2016 Instructor: Michael Eckmann Today s Topics Comments/Questions? Stacks and Queues Applications of both Priority Queues Michael Eckmann - Skidmore
More informationCS301 - Data Structures Glossary By
CS301 - Data Structures Glossary By Abstract Data Type : A set of data values and associated operations that are precisely specified independent of any particular implementation. Also known as ADT Algorithm
More informationUNIT 3
UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment
More informationMarch 13/2003 Jayakanth Srinivasan,
Statement Effort MergeSort(A, lower_bound, upper_bound) begin T(n) if (lower_bound < upper_bound) Θ(1) mid = (lower_bound + upper_bound)/ 2 Θ(1) MergeSort(A, lower_bound, mid) T(n/2) MergeSort(A, mid+1,
More informationRevision Statement while return growth rate asymptotic notation complexity Compare algorithms Linear search Binary search Preconditions: sorted,
[1] Big-O Analysis AVERAGE(n) 1. sum 0 2. i 0. while i < n 4. number input_number(). sum sum + number 6. i i + 1 7. mean sum / n 8. return mean Revision Statement no. of times executed 1 1 2 1 n+1 4 n
More informationCS8391-DATA STRUCTURES QUESTION BANK UNIT I
CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Define data structure. The data structure can be defined as the collection of elements and all the possible operations which are required for those
More informationCS200: Queues. Prichard Ch. 8. CS200 - Queues 1
CS200: Queues Prichard Ch. 8 CS200 - Queues 1 Queues First In First Out (FIFO) structure Imagine a checkout line So removing and adding are done from opposite ends of structure. 1 2 3 4 5 add to tail (back),
More informationSummer Final Exam Review Session August 5, 2009
15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationDepartment of Computer Science and Technology
UNIT : Stack & Queue Short Questions 1 1 1 1 1 1 1 1 20) 2 What is the difference between Data and Information? Define Data, Information, and Data Structure. List the primitive data structure. List the
More informationAn Introduction to Trees
An Introduction to Trees Alice E. Fischer Spring 2017 Alice E. Fischer An Introduction to Trees... 1/34 Spring 2017 1 / 34 Outline 1 Trees the Abstraction Definitions 2 Expression Trees 3 Binary Search
More informationLinear Data Structure
Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure Model wer Subject Code: 17330 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in
More informationCS6202 - PROGRAMMING & DATA STRUCTURES I Unit IV Part - A 1. Define Stack. A stack is an ordered list in which all insertions and deletions are made at one end, called the top. It is an abstract data type
More informationAdapted By Manik Hosen
Adapted By Manik Hosen Question: What is Data Structure? Ans: The logical or mathematical model of particular organization of data is called Data Structure. Question: What are the difference between linear
More informationStacks and Queues. CSE Data Structures April 12, 2002
Stacks and Queues CSE 373 - Data Structures April 12, 2002 Readings and References Reading Section 3.3 and 3.4, Data Structures and Algorithm Analysis in C, Weiss Other References 12-Apr-02 CSE 373 - Data
More informationPreface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS
Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...
More informationLecture No.04. Data Structures
Lecture No.04 Data Structures Josephus Problem #include "CList.cpp" void main(int argc, char *argv[]) { CList list; int i, N=10, M=3; for(i=1; i
More informationCISC
CISC-235 20180115+17+19 Much of the material we covered this week was already posted in the notes for last week. These notes take up where those left off, and fill in some gaps. We have discussed the notation
More informationStacks, Queues and Hierarchical Collections. 2501ICT Logan
Stacks, Queues and Hierarchical Collections 2501ICT Logan Contents Linked Data Structures Revisited Stacks Queues Trees Binary Trees Generic Trees Implementations 2 Queues and Stacks Queues and Stacks
More informationList, Stack, and Queues
List, Stack, and Queues R. J. Renka Department of Computer Science & Engineering University of North Texas 02/24/2010 3.1 Abstract Data Type An Abstract Data Type (ADT) is a set of objects with a set of
More informationCS 8391 DATA STRUCTURES
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK CS 8391 DATA STRUCTURES UNIT- I PART A 1. Define: data structure. A data structure is a way of storing and organizing data in the memory for
More informationCSE 214 Computer Science II Stack
CSE 214 Computer Science II Stack Spring 2018 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Random and Sequential Access Random
More informationCS8391-DATA STRUCTURES
ST.JOSEPH COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERI NG CS8391-DATA STRUCTURES QUESTION BANK UNIT I 2MARKS 1.Explain the term data structure. The data structure can be defined
More information1. Attempt any three of the following: 15
(Time: 2½ hours) Total Marks: 75 N. B.: (1) All questions are compulsory. (2) Make suitable assumptions wherever necessary and state the assumptions made. (3) Answers to the same question must be written
More informationStacks, Queues and Hierarchical Collections
Programming III Stacks, Queues and Hierarchical Collections 2501ICT Nathan Contents Linked Data Structures Revisited Stacks Queues Trees Binary Trees Generic Trees Implementations 2 Copyright 2002- by
More informationFundamentals of Data Structure
Fundamentals of Data Structure Set-1 1. Which if the following is/are the levels of implementation of data structure A) Abstract level B) Application level C) Implementation level D) All of the above 2.
More informationR13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)
SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)
More informationDraw a diagram of an empty circular queue and describe it to the reader.
1020_1030_testquestions.text Wed Sep 10 10:40:46 2014 1 1983/84 COSC1020/30 Tests >>> The following was given to students. >>> Students can have a good idea of test questions by examining and trying the
More informationData Structure using C++ Lecture 04. Data Structures and algorithm analysis in C++ Chapter , 3.2, 3.2.1
Data Structure using C++ Lecture 04 Reading Material Data Structures and algorithm analysis in C++ Chapter. 3 3.1, 3.2, 3.2.1 Summary Infix to Postfix Example 1: Infix to Postfix Example 2: Postfix Evaluation
More informationEnd-Term Examination Second Semester [MCA] MAY-JUNE 2006
(Please write your Roll No. immediately) Roll No. Paper Code: MCA-102 End-Term Examination Second Semester [MCA] MAY-JUNE 2006 Subject: Data Structure Time: 3 Hours Maximum Marks: 60 Note: Question 1.
More informationLab 7 1 Due Thu., 6 Apr. 2017
Lab 7 1 Due Thu., 6 Apr. 2017 CMPSC 112 Introduction to Computer Science II (Spring 2017) Prof. John Wenskovitch http://cs.allegheny.edu/~jwenskovitch/teaching/cmpsc112 Lab 7 - Using Stacks to Create a
More informationAnswers. 1. (A) Attempt any five : 20 Marks
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given
More informationData Structures and Algorithms
Data Structures and Algorithms Alice E. Fischer Lecture 6: Stacks 2018 Alice E. Fischer Data Structures L5, Stacks... 1/29 Lecture 6: Stacks 2018 1 / 29 Outline 1 Stacks C++ Template Class Functions 2
More information