Page 1

ECET 370 Entire Course (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 1 Lab 1 ECET 370 Week 2 Lab 2 ECET 370 Week 3 Lab 3 Linked Lists ECET 370 Week 4 Lab 4 Complexity of Computational Problems ECET 370 Week 5 Lab 5 Search Algorithms and Techniques ECET 370 Week 7 Lab 7 Binary Trees =================================================== =================================

ECET 370 Week 1 iLab Array Based Implementations (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 1 iLab Array-Based Implementations iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that require implementation with arrays of abstract data types, such as lists and bags. Note!Software Citation Requirements


This course uses open-source software which must be cited when used for any student work. Citation requirements are on theOpen Source Applications page. Please review the installation instruction files to complete your assignment Deliverables There are four exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Exercise 4 contains parts a, b, c and continues through part i. Keep in mind that the methods developed for each of these parts should be within the same bag class. Create a folder and name it Week 1 iLab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three exercises required for submission in the corresponding subfolder. Compress the folder Week 1 iLab, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of Array-Based Lists Back to Top Create a project using the classes in this zip file and name it "A Simple ArrayList Class." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class discussed in the lecture. Exercise 2: Implementing an Array List


Back to Top Modify the class ArrayList given in Exercise 1 by using expandable arrays. That is, if the list is full when an item is being added to this list, the elements will be moved to a larger array. The new array should have twice the size of the original array. Exercise 3: Using an Array-Based List Back to Top Using the class ArrayList completed in the previous exercise, write a program to store 1,000 random numbers, each in the interval [0, 500]. The initial size of the array in the class should be set to 100. Print the numbers. Exercise 4: Implementing a Bag Class Back to Top Create a class bag (multiset) that uses an expandable array to store the bag items. The item type must be a Java String type; that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language. Bag(): default constructor booleanisEmpty(): determines whether the bag is empty void print(): prints the bag elements intgetLength(): returns the number of items in the bag void clear(): removes all of the items from the bag void add(String item): adds an item to the bag voidremoveOne(String item): removes item from the bag; only one occurrence of item should be removed. voidremoveAll(String item): removes item from the bag; all occurrences of item should be removed. int count(String item): counts the number of occurrences of item in the bag


=================================================== =================================

ECET 370 Week 1 Lab 1 (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com General Instructions Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled “Userdefined classes." Exercises 7 and 8 use the programs in DocSharinglabeled “Using interfaces." Exercise 1: Review of classes Create a project using the classes in the DocSharing area labeled “User-defined classes." Compile it, run it, and review the code that is given carefully. Exercise 2: User-defined methods The function area of the Triangle class is the framework of the actual method. Modify it so that it calculates the area of the triangle. Write a Main class to test your area method. Note: to calculate the area of a triangle from the vertices, first find the distances between each pair of vertices to obtain the length of the sides of the triangle. Then apply Heron’s formula to calculate the area given the length of the sides. Exercise 3: Shallow versus deep copy Provide an example of shallow copy of objects and an example of deep copy of objects. Exercise 4: Passing parameters to methods Write a function that swaps two Point objects. Use the code given below: import java.util.*; public class Main { public Main() { Scanner Scanner(System.in); System.out. print("Enter x and y coordinates of first point: "); Point Point (in.nextDouble(), in.nextDouble()); System.out. print("Enter x and y coordinates of second point: "); Point Point (in.nextDouble(),


in.nextDouble()); swap(p1, p2); System.out.println(" Compile it, run it, and review the code that is given carefully. Note: The class Point implements the Comparable interface. The Comparable interface contains a single method: compareTo, which is used to compare two objects p and q of the same class type. When calling p.compareTo(q), it returns an integer. If this value is negative it means that p is smaller; if it is equal to zero then , and if the value is positive, it indicates that p is greater than q. Exercise 8: Implementation of interfaces Using the class Point in the DocSharing area labeled “Using interfaces," write an application that declares an array of Points, fills the array with random points, and finds the smallest point in the array. =================================================== =================================

ECET 370 Week 2 ilab Linked Lists (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 2 ilab Linked Lists iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that require the implementation with linked lists of abstract data types, such as lists and bags. Deliverables There are four exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully.


Exercise 1: No submission is required. Exercise 4 contains Parts a, b, c, d, e, f, g, and h. Keep in mind that the methods developed for each of these parts should be within the same bag class. Create a folder and name it Week 2 iLab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three exercises required for submission in the corresponding subfolder. Compress the folder Week 2 iLab, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of Linked Lists Back to Top Create a project using the classes in "A Simple LinkedList Class." Compile it, run it, and review the code that is given carefully. This code tests the LinkedList class provided in the lecture. Exercise 2: Implementing a Doubly Linked List Back to Top Modify the class LinkedList in Exercise 1 to make it a doubly linked list. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards: voidaddEnd(int x): create this method to add x to the end of the list. voiddisplayInReverse(): create this method to display the list elements from the last item to the first one.


Create a main class to test your DoublyLinkedList class. Exercise 3: Using a Doubly Linked List Back to Top Using the class DoublyLinkedList completed in the previous exercise, write a program to store all the prime numbers up to 100 in a DoublyLinkedList object. The numbers should be stored in such a way that when “display” is invoked, the listing will be shown in increasing order: 2, 3, 5, 7, 11, 13, 17, … . Exercise 4: Implementing a Bag Class Back to Top Create a class bag that uses a linked list to store the bag items. The item type must be a Java String type, that is, the bag will store strings of characters. The class should have the methods listed below. Create a main class to test your bag class. This main class should fill a bag with the keywords of the Java language. . Bag(): default constructor booleanisEmpty(): determines whether the bag is empty void print(): prints the bag elements intgetLength(): returns the number of items in the bag void clear(): removes all of the items from the bag void add(String item): adds an item to the bag voidremoveOne(String item): removes an item from the bag; only one occurrence of the item should be removed. int count(String item): counts the number of occurrences of an item in the bag. (Note that you can reuse the code in Exercise 1 for the LinkedList class to create your bag class. It will help you to save development time.) =================================================== =================================


ECET 370 Week 2 Lab 2 (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com General Instructions Exercises 1, 2, and 3 use the programs in DocSharinglabeled “Userdefined array list." Exercise 4 uses the programs in DocSharinglabeled “Using java.util.ArrayList." Exercise 1: Review of array-based lists Create a project using the classes in the DocSharing area labeled “User-defined array list." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class provided in the lecture. Exercise 2: A user-defined array list Modify the class ArrayList given in the lecture by adding to it the functions listed below for Exercise 2. In each case, the appropriate error message should be generated if an invalid condition occurs. For example, an error message should be generated when trying to insert an item in a given location in the list and the location is out of range. a. ArrayList(int size): create a constructor that sets the size of the array list to the value passed in size (note that the class variable SIZE cannot be final anymore). b. int length(): create this function to determine the number of items in the list (accessor function). c. intgetSize(): create this function to determine the size of the list (accessor function). d. void clear(): create this function to remove all of the items from the list. After this operation, the length of the list is zero. e. void replace(int location, int item): create this function to replace the item in the list at the position specified by location. The item should be replaced with item. f. void insert(int location, int item): create this function to add an item to the list at the position specified by location. g. void remove(int item): create this function to delete an item from the list.


All occurrences of item in the list should be removed. h. int get(int location): create a function that returns the element at location. i. public ArrayList copy(): create a function that makes a deep copy to another ArrayList object. Exercise 3: Using an array-based list Using the class ArrayList completed in the previous exercise, write a program that uses it to store 100 random numbers. Consider that each of these random numbers is an integer in the interval [0, 200]. Write the program in such a way that there are no number duplicates. Exercise 4: Review of the library class java.util.ArrayList Create a project using the classes in the DocSharing area labeled “Using java.util.ArrayList." Compile it, run it, and review the code that is given carefully. This code is the complete program given in our lecture that tests the library class java.util.ArrayList. Exercise 5: Using the library class java.util.ArrayList Rewrite Exercise 3 (above) using the class java.util.ArrayList to store the 100 random numbers. =================================================== =================================

ECET 370 Week 3 ilab The Stack and the Queue ADTs (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 3 ilab The Stack and the Queue ADTs


iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that involve the use of the stack and the queue data structures. Deliverables There are six exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercises 1 and 4: No submissions are required. Create a folder and name it Week 3 iLab. Inside this folder, create the subfolders Ex2, Ex3, Ex5, and Ex6. Place the solution to each of the four exercises required for submission in the corresponding subfolder. Compress the folder Week 3 iLab using a program like WinZip, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, 5, and 6 require software development. Place only .java files in the corresponding folders. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of the Stack ADT Back to Top Create a project using the classes in "A Simple Stack Class". Compile the project, run it, and review the code that is given carefully. This code tests the stack class provided in the lecture. Exercise 2: An Improved Stack Class Back to Top Modify the stack class to include appropriate error messages if invalid conditions occur—for example, trying to pop an item when the stack is empty. Exercise 3: Using a Stack in an Application Back to Top


Complete Project 2 at the end of Chapter 5 in our textbook: Write a Java program that uses a stack to test whether an input string is a palindrome. Exercise 11 defines "palindrome" and asks you to describe a solution to this problem. As you can see, you will need to read Exercise 11 to find the meaning of palindrome. To implement the solution to this problem, use the stack of characters from the previous exercises (1 and 2). Exercise 4: Review of the Queue ADT Back to Top Create a project using the classes in "A Simple Queue Class." Compile the project, run it, and review the code that is given carefully. This code tests the queue class provided in the lecture. Exercise 5: An Improved Queue Class Back to Top Modify the class queue to include appropriate error messages if invalid conditions occur—for example, trying to dequeue an item when the queue is empty. Exercise 6: Using a Queue in an Application Back to Top Complete Project 4 at the end of Chapter 10 in our textbook:Simulate a small airport with one runway. Airplanes waiting to take off join a queue on the ground. Planes waiting to land join a queue in the air. Only one plane can use the runway at any given time. All planes in the air must land before any plane can take off. ECET 370 Week 3 ilab The Stack and the Queue ADTs iLAB OVERVIEW Scenario and Summary The purpose of the iLab exercises is to help the student acquire skills in developing programs that involve the use of the stack and the queue data structures. Deliverables There are six exercises in this iLab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercises 1 and 4: No submissions are required.


Create a folder and name it Week 3 iLab. Inside this folder, create the subfolders Ex2, Ex3, Ex5, and Ex6. Place the solution to each of the four exercises required for submission in the corresponding subfolder. Compress the folder Week 3 iLab using a program like WinZip, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, 5, and 6 require software development. Place only .java files in the corresponding folders. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of the Stack ADT Back to Top Create a project using the classes in "A Simple Stack Class". Compile the project, run it, and review the code that is given carefully. This code tests the stack class provided in the lecture. Exercise 2: An Improved Stack Class Back to Top Modify the stack class to include appropriate error messages if invalid conditions occur—for example, trying to pop an item when the stack is empty. Exercise 3: Using a Stack in an Application Back to Top Complete Project 2 at the end of Chapter 5 in our textbook: Write a Java program that uses a stack to test whether an input string is a palindrome. Exercise 11 defines "palindrome" and asks you to describe a solution to this problem. As you can see, you will need to read Exercise 11 to find the meaning of palindrome. To implement the solution to this problem, use the stack of characters from the previous exercises (1 and 2). Exercise 4: Review of the Queue ADT Back to Top


Create a project using the classes in "A Simple Queue Class." Compile the project, run it, and review the code that is given carefully. This code tests the queue class provided in the lecture. Exercise 5: An Improved Queue Class Back to Top Modify the class queue to include appropriate error messages if invalid conditions occur—for example, trying to dequeue an item when the queue is empty. Exercise 6: Using a Queue in an Application Back to Top Complete Project 4 at the end of Chapter 10 in our textbook:Simulate a small airport with one runway. Airplanes waiting to take off join a queue on the ground. Planes waiting to land join a queue in the air. Only one plane can use the runway at any given time. All planes in the air must land before any plane can take off. =================================================== =================================

ECET 370 Week 3 Lab 3 Linked Lists (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com General Instructions Exercises 1, 2, and 3 use the programs in DocSharinglabeled “Userdefined linked list." Exercise 4 uses the programs in DocSharinglabeled “Using java.util.LinkedList." Exercise 1: Review of Linked Lists Create a project using the classes in the DocSharing area labeled “User-defined linked list." Compile it, run it, and review the code that is given carefully. This code tests the


LinkedList class provided in the lecture. Extend the class Main to test the functions isEmpty, search and remove of the class LinkedList. Exercise 2: A User-Defined Linked List Modify the class LinkedList given in the lecture by adding to it the functions listed below for Exercise 2. In each case, the appropriate error message should be generated if an invalid condition occurs. a. toString(): modify the display function to overload the toString function of the Object class. b. int length(): create this function to determine the number of items in the list (accessor function). c. void clear(): create this function to remove all of the items from the list. After this operation is completed, the length of the list is zero. d. void insertEnd(int item): create this function to insert item at the end of the list. e. void replace(int location, int item): create this function to replace the item in the list at the position specified by location. The item should be replaced with item. f. int get(int location): create a function that returns the element at the position location. Exercise 3: Using a Linked List This exercise is similar to Exercise 3 in Lab 2, but uses the LinkedList class implemented in Exercise 2 above. That is, using the class LinkedList, write a program that uses it to store 100 random numbers. Again, consider that each of these random numbers is an integer in the interval [0, 200]. Write the program in such a way that there are no number duplicates. Exercise 4: Review of the Library Class java.util.LinkedList Create a project using the class in the DocSharing area labeled “Using java.util.LinkedList." Compile it, run it, and review the code that is given carefully. This code is the complete program given in our lecture that tests the library class java.util.LinkedList. Exercise 5: Using the Library Class java.util.LinkedList Rewrite Exercise 3 (above) using the class java.util.LinkedList to store the 100 random numbers. =================================================== =================================

ECET 370 Week 4 ilab The Efficiency of Algorithms and Sorting (New Syllabus)


FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 4 ilab The Efficiency of Algorithms and Sorting iLAB OVERVIEW Scenario and Summary The purpose of the lab exercises is to help the student acquire skills in developing programs that involve algorithm analysis, recursion, and sorting. Deliverables There are four exercises in this lab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Note that some of the exercises require sections of code to be timed. To learn how to time a section of your source code, please refer to the beginning of the Projects section in Chapter 4 of our textbook. Exercises 2 and 4 require not only software development but also explanations about the results of the experiments that are conducted. Create separate Word documents to provide the details required in these exercises. Create a folder and name it Week 4 Lab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three exercises required for submission in the corresponding subfolder. Compress the folder Week 4 Lab using a program like WinZip, and place the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS


Exercise 1: Review of the Lecture Contents Back to Top Create three projects, minimum, factorial, and sorting algorithms, using the classes in Minimum Factorial Sorting Algorithms Compile them, run them, and review the code that is given carefully. These programs test the code discussed in the lecture. Exercise 2: Efficiency of Algorithms Back to Top Problem 3 in the Projects section at the end of Chapter 4 in the textbook: Find a value of n for which Loop B is faster. For which value(s) of n was Loop B faster? What have you observed in running this experiment? Any conclusions? Your observations should be entered in a separate Word document. Note: This exercise requires timing code. You can find how to time a section of code in Java at the beginning of the Projects section in Chapter 4 of the textbook. Exercise 3: Recursion Back to Top Problem 5 in the Exercises section at the end of Chapter 7 in the textbook: Write a recursive method that writes a given array backward. Consider the last element of the array first. Exercise 4: Sorting Back to Top In this week’s lecture, the algorithms quicksort and bubblesort are described. In Sorting Algorithms you can find the class ArrayList, where these sorting algorithms are implemented. Write a program that times both of them for various list lengths, filling the array lists with random numbers. Use at least 10 different list lengths, and be sure to include both small values and large values for the list lengths. Create a table to record the times. List Length Bubblesort Time (milliseconds)


Quicksort Time (milliseconds) Regarding the efficiency of both sorting methods, what conclusion can be reached from this experiment? Both the table and your conclusions should be included in a separate Word document. =================================================== =================================

ECET 370 Week 4 Lab 4 Complexity of Computational Problems (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com General Instructions Exercise 1 uses the programs in DocSharinglabeled “Minimum," “Factorial,” and “Sorting algorithms." Exercise 1: Review of the Lecture Contents Create projects using the classes in the DocSharing areas labeled “Minimum," “Factorial,” and “Sorting algorithms." Compile them, run them, and review the code that is given carefully. These programs test the code discussed in the lecture. Exercise 2: Efficiency of Algorithms Problem 2 in the Section “Projects” at the end of Chapter 9 in the textbook: find a value of n for which Loop B is faster. Exercise 3: Recursion Problem 1 in the Section “Projects” at the end of Chapter 10 in the textbook: recursive algorithm to find the square root of a given number. Exercise 4: Sorting In this week’s lecture, the algorithms quicksort and bubblesort are described and implemented. In DocSharing, under the section labeled “Sorting algorithms," you can find the class ArrayList where these sorting algorithms are implemented. Write a Java program that times both of them for various values of n. Create a table to record the times. Regarding the efficiency of both


sorting methods, what conclusion can be reached from this experiment? Note: You can probably save development time by using the program from Week 2 to generate a list of the 1000 smallest prime numbers (in random order). This list could then be used as the input to the sorting algorithms. =================================================== =================================

ECET 370 Week 5 ilab Search Techniques and Hashing (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 5 ilab Search Techniques and Hashing iLAB OVERVIEW Scenario and Summary The purpose of the lab exercises is to help the student acquire skills in developing programs that involve search algorithms and techniques. Deliverables There are four exercises in this lab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Note that one of the exercises requires sections of code to be timed. To review how to time a section of your source code, please refer to the beginning of the Projects section in Chapter 4 of our textbook. Exercise 2 requires not only software development but also explanations about the results of the experiments that are conducted. Create a separate Word document to provide the details required in the exercise. Create a folder and name it Week 5 Lab. Inside this folder, create the subfolders Ex2, Ex3, and Ex4. Place the solution to each of the three


exercises required for submission in the corresponding subfolder. Compress the folder Week 5 Lab, and place the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, and 4 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Review of the Lecture Content Back to Top Create a project using the ArrayList class and the Main class in Search Algorithms. The ArrayList class contains implementations of the first three search methods explained in this week’s lecture: sequential, sorted, and binary search. The Main class uses these three methods. These programs test the code discussed in the lecture. Compile the project, run it, and review the code that is given carefully. Exercise 2: Search Algorithms and Techniques Back to Top Expand the project developed in the previous exercise to perform the following experiment: Time the sequential search and the binary search methods several times each for randomly generated values, and record the results in a table. Do not time individual searches, but groups of them. For example, time 100 searches together or 1,000 searches together. Compare the running times of these two search methods that are obtained during the experiment. Regarding the efficiency of both search methods, what conclusion can be reached from this experiment? Both the table and your conclusions should be included in a separate Word document. Exercise 3: Searching Applications Back to Top The following problem is a variation of Project 4 in the "Projects" section of Chapter 18 in our textbook:


Consider an array data of n numerical values in sorted order and a list of two numerical target values. Your goal is to compute the smallest range of array indices that contains both of the target values. If a target value is smaller than data[0], the range should start with a -1. If a target value is larger than data[n-1], the range should end with n. For example, given the array 0 1 2 3 4 5 6 7 5 8 10 13 15 20 22 26 the following table illustrates target values and their corresponding ranges: Target Values Smellest Range of Indices 2, 8 [-1, 1] 9, 14 [1, 4] 12, 21 [2, 6] 14, 30 [3, 8] Devise and implement an algorithm that solves this problem.


Exercise 4: Hashing Back to Top Suppose that the type of key in a hashing application you are implementing is string (Sections 21.7 and 21.8 in our textbook explain hash functions for strings). Design and implement a hash function that converts a key to a hash value. Test your function by computing the hash values for the Java keywords. Was a key collision produced? =================================================== =================================

ECET 370 Week 5 Lab 5 Search Algorithms and Techniques (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com General Instructions Exercise 1 uses the programs in DocSharinglabeled “Search algorithms." Exercise 1: Review of the Lecture Content Create a project using the ArrayList class and the Main class provided in DocSharing. The ArrayList class contains implementations of the first three search methods explained in this week’s lecture: sequential, sorted, and binary search. The Main class uses these three methods. These programs test the code discussed in the lecture. Compile the project, run it, and review the code that is given carefully. Exercise 2: Search Algorithms and Techniques Expand the project developed in the previous exercise to perform the following experiment: time the three search methods several times each and record the results.


Compare the running times of the three search methods (sequential search, sorted search, and binary search) which are obtained during the experiment. What conclusions can be drawn? Exercise 3: Searching Applications Select one of the following two problems to solve: Problem 1: Design and implement an algorithm that determines whether or not a given array of elements, list1, is completely contained within another given array of elements, list2. Consider two different scenarios: 1) both arrays are sorted; 2) both arrays are unsorted. Problem 2: Design an algorithm that when given a collection of integers in an unsorted array, determines the second smallest number (or second minimum). For example, if the array consists of the values 12, 23, 9, 17, 3, the algorithm should report the value 9, since it is the second smallest number in the array. Write a function that receives an array as a parameter and returns the second smallest number. To test your function, write a program that populates an array with random numbers and then call your function. Exercise 4: Hashing Suppose that the type of key in a hashing application you are implementing is String (Sections 19.6 and 19.7 in our textbook explain hash functions for strings). Design, implement, and test a hash function that converts a key to a hash value. Assume that the size of the hash table is a prime number. =================================================== =================================

ECET 370 Week 6 ilab Binary Trees (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 6 ilab Binary Trees iLAB OVERVIEW Scenario and Summary


The purpose of the lab exercises is to help the student acquire skills in developing programs that involve the use of binary trees. We will be concentrating primarily on binary search trees, or BSTs. Deliverables There are five exercises in this lab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Create a folder and name it Week 6 Lab. Inside this folder, create the subfolders Ex2, Ex3, Ex4, and Ex5. Place the solution to each of the four exercises required for submission in the corresponding subfolder. Compress the folder Week 6 Lab, and place the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, 4, and 5 require software development. Place in the corresponding folders only .java files. Do not submit the .class files or other files or folders that are generated by the IDE. Required Software Eclipse Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Lecture Review—Binary Search Tree Back to Top Create a project using the classes BinarySearchTree, Node, and Main in Binary Search Tree. Compile the project, run it, and review the code that is given carefully. These programs test the code discussed in our lecture. Exercise 2: An Improved BST Class Back to Top Add the toString method to the class BinarySearchTree in Exercise 1. Note: The toString method returns a string representation of the object properties. By implementing toString, a BinarySearchTree object can be displayed in a simple way using System.out.print or System.out.println. For example, if bst is a BinarySearchTree object, it can be printed using System.out.println(bst). Exercise 3: Using a BST in an Application Back to Top


Create a class SimpleBag that uses a binary search tree to store the bag items.The class should have the methods listed below. Create a Main class to test your SimpleBag class. SimpleBag(): default constructor; creates an empty bag booleanisEmpty(): determines whether the bag is empty void print(): prints the SimpleBag elements void clear(): removes all of the items from the bag void add(int item): adds an item to the bag int count(int item): counts the number of occurrences of items in the bag. Exercise 4: Recursion and Binary Trees Back to Top Add a recursive function getHeight to the BinarySearchTree class in Exercise 1 that returns the height of the tree. Create a Main class to test it. Exercise 5: Using Properties of BSTs Back to Top Add methods preorderDisplay and postorderDisplay to the BinarySearchTree class in Exercise 1 to print the items in the BST listed in preorder and postorder, respectively. Create a Main class to test them. =================================================== =================================

ECET 370 Week 7 ilab Collections Framework (New Syllabus) FOR MORE CLASSES VISIT www.ecet370helps.com ECET 370 Week 7 ilab Collections Framework iLAB OVERVIEW Scenario and Summary The purpose of the lab exercises is to help the student acquire skills in developing programs that involve the use of the collections framework. Deliverables


There are five exercises in this lab, although not all of them will be required for submission. Be sure to read the following instructions carefully. Exercise 1: No submission is required. Create a folder and name it Week 7 Lab. Inside this folder, create the subfolders Ex2, Ex3, Ex4, and Ex5. Place the solution to each of the four exercises required for submission in the corresponding subfolder. Compress the folder Week 7 Lab, and drop the resulting zipped folder into the Dropbox. Note that Exercises 2, 3, 4, and 5 require software development. Place only source files in the corresponding folders. Do not submit other types of files or folders that are generated by the IDE. Exercises 2 and 4 should be implemented using the Java programming language, and Exercises 3 and 5 should be implemented using the C++ programming language. Exercise 1 requires both. Required Software Eclipse Access the software at https://lab.devry.edu . Microsoft Visual Studio 2012 Access the software at https://lab.devry.edu . iLAB STEPS Exercise 1: Lecture Review—JCF and STL Back to Top Create seven projects, JCF array list, JCF linked list, JCF sort,JCF stack, STL doubly linked list, STL stack and queue, and STL vector, using the programs in: JCF array list JCF linked list JCF sort JCF stack STL doubly linked list STL stack and queue STL vector Compile the projects, run them, and review the code that is given carefully. These programs test the code discussed in our lecture.


Exercise 2: Using the JCF ArrayList Back to Top Write a Java program to store 1,000 random numbers, each in the interval [0, 500], in a java.util.ArrayList object. Print the numbers. Exercise 3: Using the STL Vector Back to Top Write a C++ program to store the first 20 factorials: 1!, 2!, 3!, . . . , 20! in a vector object. Exercise 4: Developing an Application with JCF Back to Top Complete Project 2 at the end of Chapter 5 in our textbook: Write a Java program that uses a stack to test whether an input string is a palindrome. To implement the solution to this problem, use the stack data structure in JCF. Note that this exercise is a variation of Exercise 3 in the lab of Week 3. Exercise 5: Developing an Application with C++ STL Back to Top Complete Project 4 at the end of Chapter 10 in our textbook:Simulate a small airport with one runway. Airplanes waiting to take off join a queue on the ground. Planes waiting to land join a queue in the air. Only one plane can use the runway at any given time. All planes in the air must land before any plane can take off. To implement the solution to this problem, use the queue data structure in C++ STL. Note that this exercise is a variation of Exercise 6 in the lab of Week 3. =================================================== =================================

ECET 370 Week 7 Lab 7 Binary Trees (Devry) FOR MORE CLASSES VISIT www.ecet370helps.com Full set of lab with working programs.


Exercise 1: Lecture review: Binary Search Tree Create a project using the classes BinarySearchTree, Node, and Main in the DocSharing area labeled “The BST." Compile the project, run it, and review the code that is given carefully. These programs test the code discussed in our lecture. Exercise 2: An improved BST class Modify the class BinarySearchTree so that it contains the toString method, instead of the display method that was given originally. Exercise 3: Using a BST in an application Use a binary search tree to implement a dictionary that contains the keywords in the Java language. Test it. Note that you can use the programs from the previous exercises. For a list of the keywords in Java, visit http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.ht ml. Exercise 4: Recursion and Binary Trees Write a recursive algorithm that counts the nodes in a binary search tree. Exercise 5: Using properties of BSTs Write an algorithm getMax to find the maximum value stored in a binary search tree. ====================================================================================

ECET 370 HELPS Predictable World / ecet370helps.com  

We are dedicated to helping you exceed your career goals

ECET 370 HELPS Predictable World / ecet370helps.com  

We are dedicated to helping you exceed your career goals

Advertisement