Memorandum public override string string Node while null return public void bool false Node while null null true while public void Node new
|
|
- Olivia Booker
- 5 years ago
- Views:
Transcription
1 Memorandum public override string ToString() string s = ""; while (current!= null) s += current.element.tostring() + ", "; current = current.next; return s; //ToString() public void Sort() T temp; bool isswapped = false; do isswapped = false; while (current!= null && current.next!= null) if (current.element.compareto(current.next.element) > 0) temp = current.element; current.element = current.next.element; current.next.element = temp; isswapped = true; current = current.next; while (isswapped); //SortByElements public void Push(T item) Node newnode = new Node(item); if (this.head == null) this.head = newnode; newnode.next = head; head = newnode; count++; //Push public T Pop() if (head.next!= null) head = head.next; count--; return current.element; //Pop public T Peek() return head.element; //Peek public void Clear() this.head = null; this.count = 0; //Clear 1
2 1.2.5 public bool Contains(T item) while (current!= null) if (object.equals(current.element, item)) return true; current = current.next; return false; //Contains 1.3 static void Main(string[] args) StreamReader rdr = new StreamReader("CStack.cs"); string s = rdr.readtoend(); rdr.close(); Stack<int> stack = new Stack<int>(); bool correctbrackets = true; for (int i = 0; i < s.length; i++) char ch = s[i]; if (ch == '') stack.push(i); if (ch == '') if (stack.count == 0) //Can't pop if the stack is empty correctbrackets = false; break; stack.pop(); if (stack.count!= 0) correctbrackets = false; Console.WriteLine("Are the brackets correct? " + correctbrackets); 2. static void Main(string[] args) StreamReader rdr = new StreamReader("JEMR.txt"); string input = rdr.readtoend(); rdr.close(); Console.WriteLine("Repeating words:"); string pattern foreach (Match match in Regex.Matches(input, pattern, RegexOptions.IgnoreCase)) Console.WriteLine("0 at position 1", match.value, match.index); Console.Write("\nPress any key to exit..."); //Main 2
3 In-order (left, root, right) : 1, 2, 3, 4, 5, 6, 7, 8, 9 Pre-order (root, left, right): 5, 1, 3, 2, 4, 8, 6, 7, 9 Post-order (left, right, root): 2, 4, 3, 1, 7, 6, 9, 8, 5 Breadth-first: 5, 1, 8, 3, 6, 9, 2, 4, public void PrintTreeDFS() PrintTreeDFS(this.Root); Console.WriteLine(); private void PrintTreeDFS(Node node) if (node!= null) PrintTreeDFS(node.Left); Console.Write(node.Value + " "); PrintTreeDFS(node.Right); //PrintTreeDFS 3.4 public void PrintTreeBFS() Queue<Node> Q = new Queue<Node>(); Q.Enqueue(Root); while (Q.Count > 0) Node node = Q.Dequeue(); Console.Write(node.Value + " "); if (node.left!= null) Q.Enqueue(node.Left); if (node.right!= null) Q.Enqueue(node.Right); //PrintTreeBFS 3.5 private Node Find(dynamic value) Node node = this.root; while (node!= null) int compareto = value.compareto(node.value); if (compareto < 0) node = node.left; if (compareto > 0) node = node.right; break; //while return node; //Find public bool Contains(dynamic value) return this.find(value)!= null; //Contains 3
4 4.1 static void Main(string[] args) //Load dictionary Dictionary<string, string> dicpostalcodes = new Dictionary<string, string>(); //Step through file and add entries to dictionary StreamReader f = new StreamReader("PostalCodes.txt"); while (!f.endofstream) string[] s = f.readline().split('\t'); if (dicpostalcodes.containskey(s[0])) dicpostalcodes[s[0]] = dicpostalcodes[s[0]] + ", " + s[1]; dicpostalcodes.add(s[0], s[1]); //while f.close(); //Search for postal code Console.Write("Town: "); string stown = Console.ReadLine(); string scode = ""; if (dicpostalcodes.trygetvalue(stown, out scode)) Console.WriteLine("Postal code(s): " + scode); Console.WriteLine("Town not found."); //Opportunity to read output //Main private int GetHashCode(string Key) int hashcode = 0; for (int i = 0; i < Key.Length; i++) hashcode += (int)key[i]; return hashcode % Capacity; //GetHashCode public void Add(string Key, string Value) int hashcode = GetHashCode(Key); hashtable[hashcode ].Add (new PostalCode(Key, Value) ); //Add public string this [string Key ] get List<PostalCode> postalcodes = hashtable[gethashcode(key)].findall(code => code.town == Key); string s = ""; foreach (PostalCode postalcode in postalcodes) s += postalcode.code + ", "; return s; //get //Indexer 4
5 static void Main(string[] args) HashTable hashtable = new HashTable(100); //Step through file and add entries to hash table StreamReader f = new StreamReader("PostalCodes.txt"); while (!f.endofstream) string[] s = f.readline().split('\t'); hashtable.add(s[0], s[1]); //while f.close(); //Search for postal code Console.Write("Town: "); string stown = Console.ReadLine(); Console.WriteLine(hashTable[sTown]); //Opportunity to read output //Main //class program 5
Memorandum. 1.1 public enum Days : int { Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 }
Memorandum Question 1 1.1 public enum Days : int Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 1.2 class Temps private double[] Values = new double[7]; 1.3
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2 DATE: 12 May 2017 TIME: 3 hours MARKS: 110 ASSESSORS: Prof. P. Blignaut & Mr. G. Dollman BONUS MARKS:
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS 2614 MODULE TEST 2 DATE: 13 May 2016 TIME: 3.5 hours MARKS: 112 ASSESSOR: Prof. P.J. Blignaut BONUS MARKS: 5 MODERATOR:
More informationUNIVERSITY OF THE FREE STATE MAIN CAMPUS CSIS2614 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER:
UNIVERSITY OF THE FREE STATE MAIN CAMPUS CSIS2614 DEPARTMENT: COMPUTER SCIENCE AND INFORMATICS CONTACT NUMBER: 4012754 EXAMINATION: Additional Half Year Examination 2016 ASSESSORS: Prof. P.J. Blignaut
More informationCS2012 Programming Techniques II
27 January 14 Lecture 6 (continuing from 5) CS2012 Programming Techniques II Vasileios Koutavas 1 27 January 14 Lecture 6 (continuing from 5) 2 Previous Lecture Amortized running time cost of algorithms
More information1. Stack Implementation Using 1D Array
Lecture 5 Stacks 1 Lecture Content 1. Stack Implementation Using 1D Array 2. Stack Implementation Using Singly Linked List 3. Applications of Stack 3.1 Infix and Postfix Arithmetic Expressions 3.2 Evaluate
More informationEquality in.net. Gregory Adam 07/12/2008. This article describes how equality works in.net
Equality in.net Gregory Adam 07/12/2008 This article describes how equality works in.net Introduction How is equality implemented in.net? This is a summary of how it works. Object.Equals() Object.Equals()
More informationUniversity of KwaZulu-Natal Pietermaritzburg Campus Examinations
University of KwaZulu-Natal Pietermaritzburg Campus Examinations Data Structures COMP201 Date: November 2006. Examiners: Hugh Murrell and Satya Baboolal time limit: 3 hours max marks: 100 This paper consists
More informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationtree nonlinear Examples
The Tree ADT Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary tree implementation Examine a binary tree example 10-2
More informationECE 242 Fall 13 Exam I Profs. Wolf and Tessier
ECE 242 Fall 13 Exam I Profs. Wolf and Tessier Name: ID Number: Maximum Achieved Question 1 16 Question 2 24 Question 3 18 Question 4 18 Question 5 24 Total 100 This exam is closed book, closed notes.
More informationName Section Number. CS210 Exam #3 *** PLEASE TURN OFF ALL CELL PHONES*** Practice
Name Section Number CS210 Exam #3 *** PLEASE TURN OFF ALL CELL PHONES*** Practice All Sections Bob Wilson OPEN BOOK / OPEN NOTES: You will have all 90 minutes until the start of the next class period.
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationCMSC 132, Object-Oriented Programming II Summer Lecture 9:
CMSC 132, Object-Oriented Programming II Summer 2018 Lecturer: Anwar Mamat Lecture 9: Disclaimer: These notes may be distributed outside this class only with the permission of the Instructor. 9.1 QUEUE
More informationThe code XXX1XXX, XXX2XXX, XXX3XXX represents pieces of code that are missing from the method that are needed to make it work properly.
1) ITERATION (FOR) public void createtriangle(int n) for ( XXX1XXX ) for ( XXX2XXX ) System.out.print( XXX3XXX ); System.out.print("\n"); The code XXX1XXX, XXX2XXX, XXX3XXX represents pieces of code that
More informationDNHI Homework 3 Solutions List, Stacs and Queues
Solutions List, Stacs and Queues Problem 1 Given the IntegerQueue ADT below state the return value and show the content of the, initially empty, queue of Integer objects after each of the following operations.
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 7 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationCIS2168 Fall 2014 Midterm
CIS2168 Fall 2014 Midterm Short Answer (5 points each) 1 In the Array implementation of Queue, what does the folloing code do? q = (E[]) new Object[10]; 2 Assume the Stack size is fixed and the size is
More informationIST311 Chapter 8: C# Collections - Index-Sequential Search List & Dictionary PROGRAM
IST311 Chapter 8: C# Collections - Index-Sequential Search List & Dictionary PROGRAM class Program static void Main(string[] args) //create a few employees Employee e1 = new Employee(1111111, "Tiryon",
More informationIntroducing Hashing. Chapter 21. Copyright 2012 by Pearson Education, Inc. All rights reserved
Introducing Hashing Chapter 21 Contents What Is Hashing? Hash Functions Computing Hash Codes Compressing a Hash Code into an Index for the Hash Table A demo of hashing (after) ARRAY insert hash index =
More informationCMSC 132: Object-Oriented Programming II. Stack and Queue
CMSC 132: Object-Oriented Programming II Stack and Queue 1 Stack Allows access to only the last item inserted. An item is inserted or removed from the stack from one end called the top of the stack. This
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More information9 Hashtables and Dictionaries
9 Hashtables and Dictionaries Chapter 9 Contax T Concrete Stairs HashTables and Dictionaries Learning Objectives Describe the purpose and use of a hashtable Describe the purpose and use of a dictionary
More informationArrays, Strings and Collections
Arrays Arrays can be informally defined as a group of variables containing values of the same type and that in some way or another they are related. An array has a fixed size that is defined before the
More informationspeller.c dictionary contains valid words, one per line 1. calls load on the dictionary file
mispellings speller.c 1. calls load on the dictionary file dictionary contains valid words, one per line 2. calls check on each word in the text file and prints all misspelled words 3. calls size to determine
More informationStack ADT. ! push(x) puts the element x on top of the stack! pop removes the topmost element from the stack.
STACK Stack ADT 2 A stack is an abstract data type based on the list data model All operations are performed at one end of the list called the top of the stack (TOS) LIFO (for last-in first-out) list is
More information204111: Computer and Programming
204111: Computer and Programming Week 4: Control Structures t Monchai Sopitkamon, Ph.D. Overview Types of control structures Using selection structure Using repetition structure Types of control ol structures
More informationCIS Fall Data Structures Midterm exam 10/16/2012
CIS 2168 2012 Fall Data Structures Midterm exam 10/16/2012 Name: Problem 1 (30 points) 1. Suppose we have an array implementation of the stack class, with ten items in the stack stored at data[0] through
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS2614 MODULE TEST 1
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS2614 MODULE TEST 1 DATE: 18 March 2016 MARKS: 165 ASSESSOR: Prof. P.J. Blignaut (Bonus 8) MODERATOR: Dr T. Beelders TIME:
More informationCS101 Part 2: Practice Questions Algorithms on Arrays, Classes and Objects, String Class, Stack Class
CS1 Part 2: Algorithms on Arrays, Classes and Objects, String Class, Stack Class 1. Write a method that, given two sorted arrays of integers, merges the two arrays into a single sorted array that is returned.
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 8 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationTask 2 What is printed out when the code is executed?
Task 1 What is printed out when the code is executed? public class Class1 { public static void main(string[] args) { int array[] = {14,5,7; for (int counter1 = 0; counter1 < array.length; counter1++) {
More informationSTANDARD ADTS Lecture 17 CS2110 Spring 2013
STANDARD ADTS Lecture 17 CS2110 Spring 2013 Abstract Data Types (ADTs) 2 A method for achieving abstraction for data structures and algorithms ADT = model + operations In Java, an interface corresponds
More informationCS24 Week 4 Lecture 2
CS24 Week 4 Lecture 2 Kyle Dewey Overview Linked Lists Stacks Queues Linked Lists Linked Lists Idea: have each chunk (called a node) keep track of both a list element and another chunk Need to keep track
More informationData Structures and Object-Oriented Design III. Spring 2014 Carola Wenk
Data Structures and Object-Oriented Design III Spring 2014 Carola Wenk Array-Based Stack vs. DynamicStack public class ArrayStack { final static int DEFAULT_CAPACITY=50; private int[] S; private int top;
More informationEXAMINATIONS 2016 TRIMESTER 2
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
More informationStacks and Queues as Collections
An abstract data type (ADT) is a set of data and the particular operations that are allowed on that data Data Type is really about techniques managing collections of data in certain ways Abstract means
More information16. Dynamic Data Structures
Data Structures 6. Dynamic Data Structures A data structure is a particular way of organizing data in a computer so that it can be used efficiently Linked lists, Abstract data types stack, queue, Sorted
More informationRecursive Objects. Singly Linked List (Part 2)
Recursive Objects Singly Linked List (Part 2) 1 Operations at the head of the list operations at the head of the list require special handling because there is no node before the head node 2 Adding to
More informationCSE143 Summer 2008 Final Exam Part B KEY August 22, 2008
CSE143 Summer 2008 Final Exam Part B KEY August 22, 2008 Name : Section (eg. AA) : TA : This is an open-book/open-note exam. Space is provided for your answers. Use the backs of pages if necessary. The
More informationחומר עזר לבחינה מבוא למדעי המחשב
שיטות במחלקה Object // Indicates whether some other object is "equal to" // this one. boolean equals(object other) // Returns a string representation of the object. String tostring() // Returns the length
More informationThe Stack ADT. Stacks. The Stack ADT. The Stack ADT. Set of objects in which the location an item is inserted and deleted is prespecified.
The Stack ADT Stacks Set of objects in which the location an item is inserted and deleted is prespecified Stacks! Insert in order! Delete most recent item inserted! LIFO - last in, first out Stacks 2 The
More informationLesson11-Inheritance-Abstract-Classes. The GeometricObject case
Lesson11-Inheritance-Abstract-Classes The GeometricObject case GeometricObject class public abstract class GeometricObject private string color = "White"; private DateTime datecreated = new DateTime(2017,
More informationEXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction
More informationImplementing Lists, Stacks, Queues, and Priority Queues
Implementing Lists, Stacks, Queues, and Priority Queues CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 1 Objectives To design common features of lists in
More informationCosc 241 Programming and Problem Solving Lecture 9 (26/3/18) Collections and ADTs
1 Cosc 241 Programming and Problem Solving Lecture 9 (26/3/18) Collections and ADTs Michael Albert michael.albert@cs.otago.ac.nz Keywords: abstract data type, collection, generic class type, stack 2 Collections
More informationData Structures. COMS W1007 Introduction to Computer Science. Christopher Conway 1 July 2003
Data Structures COMS W1007 Introduction to Computer Science Christopher Conway 1 July 2003 Linked Lists An array is a list of elements with a fixed size, accessed by index. A more flexible data structure
More informationTopic 14. The BinaryTree ADT
Topic 14 The BinaryTree ADT Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary tree implementation Examine a binary tree
More informationIT 313 Advanced Application Development
Page 1 of 7 IT 313 Advanced Application Development Practice Midterm Exam Part A. Multiple Choice Questions. Answer all questions. Optional: supply a reason or show work for partial credit in case you
More informationa graph is a data structure made up of nodes in graph theory the links are normally called edges
1 Trees Graphs a graph is a data structure made up of nodes each node stores data each node has links to zero or more nodes in graph theory the links are normally called edges graphs occur frequently in
More informationinside: THE MAGAZINE OF USENIX & SAGE August 2003 volume 28 number 4 PROGRAMMING McCluskey: Working with C# Classes
THE MAGAZINE OF USENIX & SAGE August 2003 volume 28 number 4 inside: PROGRAMMING McCluskey: Working with C# Classes & The Advanced Computing Systems Association & The System Administrators Guild working
More informationDM550 Introduction to Programming part 2. Jan Baumbach.
DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net BINARY SORTING TREES 2 Binary Sort Tree special binary tree invariant for all subtrees: all elements
More informationThis is an open-book test. You may use the text book Be Sharp with C# but no other sources, written or electronic, will be allowed.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 124 DATE: 1 September 2014 TIME: 3 hours MARKS: 105 ASSESSORS: Prof. P.J. Blignaut BONUS MARKS: 3 MODERATOR: Dr. L. De Wet
More informationPrinciples of Computer Science
Principles of Computer Science Binary Trees 08/11/2013 CSCI 2010 - Binary Trees - F.Z. Qureshi 1 Today s Topics Extending LinkedList with Fast Search Sorted Binary Trees Tree Concepts Traversals of a Binary
More informationDM537 Object-Oriented Programming. Peter Schneider-Kamp.
DM537 Object-Oriented Programming Peter Schneider-Kamp petersk@imada.sdu.dk! http://imada.sdu.dk/~petersk/dm537/! ABSTRACT DATA TYPES FOR (BINARY) TREES 2 Trees trees store elements non-sequentially every
More informationCS/ENGRD2110: Final Exam
CS/ENGRD2110: Final Exam 11th of May, 2012 NAME : NETID: The exam is closed book and closed notes. Do not begin until instructed. You have 150 minutes. Start by writing your name and Cornell netid on top!
More informationChapter 9 STACK, QUEUE
Chapter 9 STACK, QUEUE 1 LIFO: Last In, First Out. Stacks Restricted form of list: Insert and remove only at front of list. Notation: Insert: PUSH Remove: POP The accessible element is called TOP. Stack
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationThe class Object. Lecture CS1122 Summer 2008
The class Object http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html Lecture 10 -- CS1122 Summer 2008 Review Object is at the top of every hierarchy. Every class in Java has an IS-A relationship
More informationBinary Search Trees. EECS 214, Fall 2018
Binary Search Trees EECS 214, Fall 2018 2 A data structure for dictionaries There are several data structures that we can use to represent dictionaries: A list of keys-value pairs A hash table An array
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #15: October 21, 2015 1/34 Generic classes and types Generic programming is the creation of programming constructs that can be usedwith many different types.
More informationBuilding Java Programs
Building Java Programs Chapter 16 References and linked nodes reading: 16.1 2 Value semantics value semantics: Behavior where values are copied when assigned, passed as parameters, or returned. All primitive
More informationCMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011
CMPSCI 187: Programming With Data Structures Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 Implementing Stacks With Linked Lists Overview: The LinkedStack Class from L&C The Fields and
More informationIntroduction to Linked Data Structures
Introduction to Linked Data Structures A linked data structure consists of capsules of data known as nodes that are connected via links Links can be viewed as arrows and thought of as one way passages
More informationName CPTR246 Spring '17 (100 total points) Exam 3
Name CPTR246 Spring '17 (100 total points) Exam 3 1. Linked Lists Consider the following linked list of integers (sorted from lowest to highest) and the changes described. Make the necessary changes in
More informationUnit 4: Stacks and Queues
Unit 4: Stacks and Queues Engineering 4892: Data Structures Faculty of Engineering & Applied Science Memorial University of Newfoundland June 1, 2011 ENGI 4892 (MUN) Unit 4 June 1, 2011 1 / 24 1 Stacks
More informationCSC 222: Computer Programming II. Spring 2005
CSC 222: Computer Programming II Spring 2005 Stacks and recursion stack ADT push, pop, peek, empty, size ArrayList-based implementation, java.util.stack application: parenthesis/delimiter matching postfix
More informationOutline. An Application: A Binary Search Tree. 1 Chapter 7: Trees. favicon. CSI33 Data Structures
Outline Chapter 7: Trees 1 Chapter 7: Trees Approaching BST Making a decision We discussed the trade-offs between linked and array-based implementations of sequences (back in Section 4.7). Linked lists
More informationCS171 Midterm Exam. October 29, Name:
CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and
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 informationAlgorithm and Data Structures, Supplemental Solution 2010
Algorithm and Data Structures, Supplemental Solution 00 Question ( marks) (a) marks class Stack { public: void push(int x); int pop(void); bool isempty(); Stack() { top = NULL; void display(); ; private:
More informationEXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION
More informationJava Memory Management
Java Memory Management Memory Allocation in Java When a program is being executed, separate areas of memory are allocated for each code (classes and interfaces) objects running methods 1-2 Memory Areas
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 8 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationBuilding Java Programs
Building Java Programs Chapter 16 References and linked nodes reading: 16.1 2 Recall: stacks and queues stack: retrieves elements in reverse order as added queue: retrieves elements in same order as added
More informationCSC 273 Data Structures
CSC 273 Data Structures Lecture 3- Stacks Some familiar stacks What is a stack? Add item on top of stack Remove item that is topmost Last In, First Out LIFO Specifications of the ADT Stack Specifications
More informationDo not turn to the next page until the start of the exam.
Principles of Java Language with Applications, PIC20a E. Ryu Winter 2017 Final Exam Monday, March 20, 2017 3 hours, 8 questions, 100 points, 11 pages While we don t expect you will need more space than
More informationAnnouncements. Container structures so far. IntSet ADT interface. Sets. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am
Announcements Today s topic: Hashing (Ch. 10) Next topic: Graphs Break around 11:45am Container structures so far Array lists O(1) access O(n) insertion/deletion (average case), better at end Linked lists
More informationThis is an open-book test. You may use the text book Be Sharp with C# but no other sources, written or electronic, will be allowed.
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS RIS 124 DATE: 5 September 2011 TIME: 3½ hours MARKS: 150 ASSESSORS: Prof. P.J. Blignaut & Mr. M.B. Mase MODERATOR: Dr. A. van
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationUNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614
UNIVERSITY OF THE FREE STATE DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS CSIS1614 DATE: 7 May 2015 MARKS: 130 ASSESSOR: Prof. P.J. Blignaut (Bonus marks: 5) MODERATOR: Dr. L. de Wet TIME: 180 minutes
More informationCSCD 326 Data Structures I Stacks
CSCD 326 Data Structures I Stacks 1 Stack Interface public interface StackInterface { public boolean isempty(); // Determines whether the stack is empty. // Precondition: None. // Postcondition: Returns
More informationWITH SOLUTIONS!!! WARNING: THIS COPY CONTAINS SOLUTIONS!!! COMP103 Introduction to Data Structures and Algorithms
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2007 SUMMER TRIMESTER COMP103 Introduction
More informationLinked Lists. References and objects
Linked Lists slides created by Marty Stepp http://www.cs.washington.edu/143/ Modified by Sarah Heckman Reading: RS Chapter 16 References and objects In Java, objects and arrays use reference semantics.
More informationC++ - Lesson 2 This is a function prototype. a' is a function that takes an integer array argument and returns an integer pointer.
C++ - Lesson 2 1. Explain the following declarations: a) int *a(int a[]); This is a function prototype. 'a' is a function that takes an integer array argument and returns an integer pointer. b) const char
More informationComputer Science 302 Spring 2007 Practice Final Examination: Part I
Computer Science 302 Spring 2007 Practice Final Examination: Part I Name: This practice examination is much longer than the real final examination will be. If you can work all the problems here, you will
More informationEXAMINATIONS 2012 MID YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 MID YEAR COMP103 Introduction to Data
More informationCSE 143 Lecture 16. Binary Search Trees. read slides adapted from Marty Stepp and Hélène Martin
CSE 143 Lecture 16 Binary Search Trees read 17.3-17.4 slides adapted from Marty Stepp and Hélène Martin http://www.cs.washington.edu/143/ Binary search trees binary search tree ("BST"): a binary tree where
More informationAdvanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition
11 Features Advanced Object-Oriented Programming C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives 2 Chapter
More informationDM537/DM550 Object-Oriented Programming. Jan Baumbach
DM537/DM550 Object-Oriented Programming Jan Baumbach jan.baumbach@imada.sdu.dk! http://www.baumbachlab.net!! Adopted from previous slides of Peter Schneider-Kamp.! ABSTRACT DATA TYPES FOR (BINARY) TREES
More informationStandard ADTs. Lecture 19 CS2110 Summer 2009
Standard ADTs Lecture 19 CS2110 Summer 2009 Past Java Collections Framework How to use a few interfaces and implementations of abstract data types: Collection List Set Iterator Comparable Comparator 2
More informationCOMP 103 Introduction to Data Structures and Algorithms
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:..................... EXAMINATIONS 2005 END-YEAR COMP 103 Introduction to Data
More informationLet s get started! You first need to download Visual Studio to edit, compile and run C# programs. Download the community version, its free.
C# Mini Lessons last update May 15,2018 From http://www.onlineprogramminglessons.com These C# mini lessons will teach you all the C# Programming statements you need to know, so you can write 90% of any
More informationChapter 10 Linked Lists A
Data Structures for Java William H. Ford William R. Topp Chapter 10 Linked Lists A Bret Ford 2005, Prentice Hall Introducing Linked Lists To insert or remove an element at an interior location in an ArrayList
More informationCS 307 Final Spring 2009
Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2009 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. 3. You have 3 hours to
More informationThe dictionary problem
6 Hashing The dictionary problem Different approaches to the dictionary problem: previously: Structuring the set of currently stored keys: lists, trees, graphs,... structuring the complete universe of
More informationAgenda. Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList!
Implementations I 1 Agenda Inner classes and implementation of ArrayList Nested classes and inner classes The AbstractCollection class Implementation of ArrayList! Stack and queues Array-based implementations
More informationAnnouncements. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am
Announcements Today s topic: Hashing (Ch. 10) Next topic: Graphs Break around 11:45am 1 Container structures so far Array lists O(1) access O(n) insertion/deletion (average case), better at end Linked
More informationCMSC 206: Data Structures Final Exam Reference May 2018
CMSC 206: Data Structures Final Exam Reference May 2018 public interface BMCSet /** Adds a new item to the set * @param item The new item to add to the set * @return true if the item is a new item added
More informationProgramming Abstractions
Programming Abstractions C S 1 0 6 B Cynthia Lee Today s Topics ADTs Stack Example: Reverse-Polish Notation calculator Queue Example: Mouse Events Stacks New ADT: Stack stack.h template
More information