CSC215 Homework Homework 11 Due date: Dec 19, 2016.

Slides:



Advertisements
Similar presentations
Chapter 5 introduces the often- used data structure of linked lists. This presentation shows how to implement the most common operations on linked lists.
Advertisements

Linked List 1. Introduction to Linked List 2. Node Class 3. Linked List 4. The Bag Class with Linked List.
418115: II. Linked List A linked list can be thought of a chain of linked list elements. A linked list element contains a single data item, and contains.
Senem Kumova Metin Spring2009 STACKS AND QUEUES Chapter 10 in A Book on C.
© 2004 Goodrich, Tamassia Linked Lists1. © 2004 Goodrich, Tamassia Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 7 : September 8.
Chapter 13 Pointers and Linked Lists. Nodes and Linked Lists Linked list: A sequence of nodes in which each node is linked or connected to the node preceding.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Stacks CS-240 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed in reverse.
Linked Lists1 Part-B3 Linked Lists. Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data structure consisting of a sequence.
Kymberly Fergusson CSE1303 Part A Data Structures and Algorithms Summer Semester 2003 Lecture A8 – Linked Stacks and Linked Queues.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Singly Linked Lists - Ed. 2, 3: Chapter 4 - Ed. 4.: Chapter 3.
Stacks CS-240 & CS-341 Dick Steflik. Stacks Last In, First Out operation - LIFO As items are added they are chronologically ordered, items are removed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation – FIFO As items are added they are chronologically ordered, items are removed.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Lists 1. Introduction Data: A finite sequence of data items. Operations: Construction: Create an empty list Empty: Check if list is empty Insert: Add.
Lab 7 Queue ADT. OVERVIEW The queue is one example of a constrained linear data structure. The elements in a queue are ordered from least recently added.
Lists, Stacks and Queues in C Yang Zhengwei CSCI2100B Data Structures Tutorial 4.
EASTERN MEDITERRANEAN UNIVERSITY Stacks EENG212 –Algorithms and Data Structures.
CSS446 Spring 2014 Nan Wang.  To understand the implementation of linked lists and array lists  To analyze the efficiency of fundamental operations.
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Generic lists Vassilis Athitsos. Problems With Textbook Interface? Suppose that we fix the first problem, and we can have multiple stacks. Can we have.
UNIT II Queue. Syllabus Contents Concept of queue as ADT Implementation using linked and sequential organization. – linear – circular queue Concept –
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department.
Abstract Data Types and Stacks CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Lab-12 Keerthi Nelaturu. BitList Stores bit values in Linked List Has to be stored in right to left order Example :
CS261 Data Structures Linked Lists - Introduction.
ENEE150 – 0102 ANDREW GOFFIN Dynamic Memory. Dynamic vs Static Allocation Dynamic  On the heap  Amount of memory chosen at runtime  Can change allocated.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
1 Midterm 1 on Friday February 12 Closed book, closed notes No computer can be used 50 minutes 4 questions Write a function Write program fragment Explain.
Stacks This presentation shows – how to implement the stack – how it can be used in real applications.
The Linked List Data Structure Mugurel Ionu Andreica Spring 2012.
الطابور QUEUE (abstract data type) واحد من هياكل البيانات الخطية الشائعة الاستخدام داخل البرامج. يحتوي علي عناصر من نفس النوع. من أنواع البيانات الخطية.
  A linked list is a collection of components called nodes  Every node (except the last one) contains the address of the next node  The address of.
Abstract Data Types and Stacks CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington Last updated: 2/17/
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Abstract Data Types Queues Dale Roberts, Lecturer
CSC215 Lecture Data Structures.
Lists, Stacks and Queues in C
Stacks and Queues Chapter 4.
Abstract Data Types and Stacks
Linked lists.
Sequences 8/2/ :13 AM Linked Lists Linked Lists.
Basic Data Structures – Continued (Queues)
CSC172 Data Structures Linked Lists (C version)
Stack and Queue.
Data Structures Linked list.
Programmazione I a.a. 2017/2018.
Stack Lesson xx   This module shows you the basic elements of a type of linked list called a stack.
Pointers and Linked Lists
Abstract Data Types (ADTs)
Stack ADT & Modularity 2 implementations of the Stack abstract data type: Array Linked List Program design: modularity, abstraction and information hiding.
Recursion.
Lists.
Linked Lists: Implementation of Queue & Deque
Cs212: Data Structures Computer Science Department Lab 7: Stacks.
Programming Linked Lists.
Sequences 12/8/2018 3:02 AM Linked Lists Linked Lists.
Review & Lab assignments
Abstract Data Types and Stacks
ECE 103 Engineering Programming Chapter 62 Stack Implementation
Stacks CS-240 Dick Steflik.
Intro to OOP with Java, C. Thomas Wu By : Zanariah Idrus
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
Linked lists.
Abstract Data Types Stacks CSCI 240
Abstract Data Types and Stacks
Presentation transcript:

CSC215 Homework Homework 11 Due date: Dec 19, 2016

Question 1 : implement the function remove_nth that is declared with the prototype given below. void* remove_nth(LinkedList* ll, int n); /* corrected! */ removes the node at position n (head is at position 0) and returns the data stored in it if possible, or NULL otherwise. Node and LinkedList are defined as follows: typedef struct Node Node; Node* new_node(void*); typedef struct LinkedList LinkedList; struct Node{ void* data; Node* next; }; struct LinkedList { Node* head; };

Question 2 : Stack S1 is empty, and Stack S2 is not Question 2 : Stack S1 is empty, and Stack S2 is not. Write the statements required to copy elements of S2 to S1 in the same order. The following are defined already: typedef struct Stack Stack; Stack* new_stack(); void* pop(Stack* s); void push(Stack* s, void* data); typedef struct Queue Queue; Stack* new_queue(); void* serve(Queue* q); void enqueue(Queue* q, void* data); You do not need to redefine any of them.