For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled “User-defined classes."
Exercises 7 and 8 use the programs in DocSharinglabeled “Using interfaces."
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled “User-defined classes."
Exercises 7 and 8 use the programs in DocSharinglabeled “Using interfaces."
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled “User-defined classes."
Exercises 7 and 8 use the programs in DocSharinglabeled “Using interfaces."
Writea program that defines a template function named add(). Thisfunction tak...licservernoida
Writea program that defines a template function named add(). Thisfunction takes two
arguments, add two variables and then return thesum.
Inmain function, define two variables of type int, two variables oftype float and two objects
callthe add() function three times for these different datatypes.
Note:String is auser
-
When template function will be calledto add two objects of type String then it must
concatenate
twostrings.
Youroutput should look like this:
SampleOutput:
Enter twointeger values to be added
EnterFirst value:12
EnterSecond value:25
Enter twofloat values to be added
EnterFirst value:13.5
EnterSecond value:14.2
Enter twoStrings to be added
EnterFir
st value:Virtual
EnterSecond value:University
Additionof two variables of different data types
Sum ofvalues of type int = 37
Sum ofvalues of type float = 27.7
Sum ofvalues of type String = VirtualUniversity
In this tutorial, we discuss the Iterators that enables to cycle through the elements of a collection. Then we check out the nested classes and complete the tutorial with Maps and some exercises.
Check out rest of the Tutorials: https://berksoysal.blogspot.com/2016/06/java-se-tutorials-basics-exercises.html
Writea program that defines a template function named add(). Thisfunction tak...licservernoida
Writea program that defines a template function named add(). Thisfunction takes two
arguments, add two variables and then return thesum.
Inmain function, define two variables of type int, two variables oftype float and two objects
callthe add() function three times for these different datatypes.
Note:String is auser
-
When template function will be calledto add two objects of type String then it must
concatenate
twostrings.
Youroutput should look like this:
SampleOutput:
Enter twointeger values to be added
EnterFirst value:12
EnterSecond value:25
Enter twofloat values to be added
EnterFirst value:13.5
EnterSecond value:14.2
Enter twoStrings to be added
EnterFir
st value:Virtual
EnterSecond value:University
Additionof two variables of different data types
Sum ofvalues of type int = 37
Sum ofvalues of type float = 27.7
Sum ofvalues of type String = VirtualUniversity
In this tutorial, we discuss the Iterators that enables to cycle through the elements of a collection. Then we check out the nested classes and complete the tutorial with Maps and some exercises.
Check out rest of the Tutorials: https://berksoysal.blogspot.com/2016/06/java-se-tutorials-basics-exercises.html
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
Goals
1)
Be able to work with individual bits in java
.
2)
Understand the serializable interface.
3)
Understand the comparable interface.
4)
Answer questions about a general-purpose class to be developed.
5)
Understand the use of a driver program for ‘glass box’ debugging.
6)
Develop a program that can grade true/false tests.
Synthesis Questions
1.
Why is it a good idea to test a general class with a driver program before trying to use it?
2.
What is the difference between black box and glass box debugging?
3.
In pseudo-code, describe
CreateTest.java.
4.
In pseudo code, describe the driver program that is provided below.
5.
If x = 37, y=23, z=-110, r=-32 answer the following questions. Assume that we are working with bytes. To answer these questions, you will need to convert from decimal to binary. Remember that
System.out.println
DOES NOT print binary values. You will need to convert your results to decimal. Of course you can verify your results by computer. Remember that there will be questions like this on the quiz, so try them yourself first.
a.
System.out.println
(
x&y
);
b.
System.out.println
(
x^y
);
c.
System.out.println
(~
x|y
);
d.
System.out.println
(~x>>2);
e.
System.out.println
((byte)(z<<(~r>>4)));
f.
System.out.println
((byte)(x + (x<<1) + (x<<2) + (x<<3)));
g.
System.out.println
(y>>>3);
h.
System.out.println
(
x&y|z^r
);
i.
System.out.println
(~x + x);
j.
System.out.println
(x|(3<<4));
6.
In
about
a sentence, give a reasonable example of when the following operators would be useful when working with strings of bits.
a.
or operation (|):
b.
and operation (&):
c.
exclusive or operation (^):
d.
left shift operation: (<<):
7.
Suppose we need to create a multiple-choice exam, where each question has four possible choices. Briefly describe (in a few sentences) how we could create a new class that uses inheritance that would allow this. Giving class API and a brief description of the needed methods would also suffice.
8.
Suppose we needed to modify the
BitMap
class to handle a bit stream of up to
16384
bits. Briefly describe the changes necessary to handle this refinement. Can you think of a way that the maximum number of bits to be handled is completely flexible?
Description
1)
The first step is to develop a general-purpose class that will be able to perform operations on strings of bits. The class API follows:
public class
BitMap
implements Comparable,
Serializable
{ public static final int BITSIZE = 64;
private
long bitString;
public BitMap
() // Three constructors.
public
BitMap
(String s)
throws
IndexOutOfBoundsException,ArithmeticException
public
BitMap
(
boolean
[] bits)
throws
IndexOutOfBoundsException
private
long
bitMask
(
int
b) // Other class methods.
public void
setBit
(
int
b)
public void
clearBit
(
int
b)
public
boolean
checkBit
(
int
b)
public
int
countTrue
()
public void
clearAll()
public void
setAll()
.
The second programming assignment (HW4) is designed to help you ga.docxoreo10
The second programming assignment (HW4) is designed to help you gain
experience with object oriented programming in Java.
The given file for hw4, "hw4.given.tar.gz", is on the class web page.
To untar and unzip the file, execute
tar -xzvf hw4.given.tar.gz
It will expand to create a directory called hw4, which contains sub-
directories part0, ..., part9, one for each part of the assignment.
Each part has a Makefile. Don't modify them.
Main.java, which is different for each part, is used to test your code
by creating objects, invoking methods, etc.
As you did on the previous assignment, you'll be using the tester tool
for testing.
Proceed similarly to what you did on the previous programming
assignment:
cd part0
# add a bunch of code
make
# if make gives errors, fix them and make again.
../tester
# if tester gives errors, fix them and repeat this cycle.
In Part 7 (only), additional tests (in Main.java and correct output
files) check that the iterators' next() methods give an error if
they're invoked when no elements remain in their collection. (In
subsequent parts, such erroneous behavior results in an exception, so
the testing doesn't use these extra tests.)
Similar to the last assignment, each part builds off the last. When
you're finished with one part,
copy all .java files ***EXCEPT Main.java*** to the next part.
Then modify these copies to start your solution for the next part.
***Exception: again, don't copy Main.java from part to part.***
See the documentation on tester (on the class web page) for details on
its use.
As always, get started early to avoid the last minute rush!
ECS140A-F16-06 October 18, 2016
ASSIGNMENT 4: Java object oriented program
Due: October 27, 2016
Overview
The purpose of this assignment is for you to gain experience with object oriented programming in
Java: in particular, the ideas of inheritance, dynamic binding (virtual methods), overriding and
overloading methods, iterators (aka generators). It will also give you some exposure to how some
programming language features are implemented, i.e., what happens "behind the scenes" when
you execute a program. Although no language provides the exact features in this assignment, a
number of languages (e.g., Awk, Icon, LISP, CLU) do provide similar features. (In fact, you
could define a little language, using techniques from first program, that would contain features
like those in this assignment.)
Your program needs to provide several abstractions. The first abstraction is an Element, of which
there are three kinds: EBoolean, EInteger, and EString. The second abstraction is an EList of Ele-
ment; associated with the EList abstraction is EListIt, which iterates over a list. Details of these
are given below in each part of this assignment.
N.B., you are restricted as to how you write your code. See “Details” before you start coding.
1
ECS140A-F16-06 October 18, 20 ...
I am Stuart M. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from, the University of Greenwich, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++. Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
OverviewUsing the C-struct feature, design, implement and .docxalfred4lewis58146
Overview
Using the C-struct feature, design, implement and test a new (programmer-defined) data type that can be used to represent and manipulate a collection of sorted integers. Such a data type can be used, for instance, by an instructor to process test scores (assuming test scores are recorded as integral values); each instance (object) of the data type would be able to represent a group of related test scores in that case. The operations supported should include the following:
Checking to see if the collection is empty.
NOTE: A collection is empty if it doesn't contain any values.
Finding the number of values in the collection.
Adding a new value to the collection.
NOTE:
You should NOT simply append the new item to the end of the array and then use a sorting algorithm of some kind to sort the array. You also should NOT use any temporary arrays to perfom the insertion.
TIP:
Adopt/adapt the StoreOrdered function of Assignment 4.
Finding the collection's lowest/highest value.
NOTE:
The lowest/highest value is undefined if the collection is empty.
Finding the value at a given position in the collection, with position starting at 1 (i.e., array index 0 corresponds to position 1, array index 1 corresponds to position 2, and so on).
NOTE:
A positional value is undefined if the collection is empty.
Finding the collection's average.
NOTE:
The average is undefined if the collection is empty.
Removing an occurrence (if exists) of a specified value from the collection.
Finding the number of occurences of a specified value in the collection.
Resetting the collection to an empty collection.
Adding a given collection into another collection.
NOTE:
The given collection (addend) and the collection to be added to (benend) may be the same collection before the operation takes place (in which case the operation will result in "each of the items in the original collection is duplicated exactly once").
TIP:
The "adding a new value to collection" function (assuming implemented correctly) should prove useful here.
Combining two given collections into a third one (which is a new collection to be returned).
TIP:
The "adding a new value to collection" function (assuming implemented correctly) should prove useful here.
Testing to see if two given collections are identical.
NOTE:
Two collections are identical if they contain the same number of items and the values contained in every corresponding pair of items are equal.
Some Specifics
You will use a fixed-sized, compile-time array (and other supporting data members) to implement the new data type that can be used to declare variables (objects) each of which can represent a collection of up to MAX_SIZE integers. For the purpose of testing, set MAX_SISE to 10; your design and implementation of the data type, however, should enable the maximum size to be easily modified, i.e., only need to change the value that MAX_SIZE is set to.
Goal
To gai.
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
Objectives
Assignment 09: Applications of Stacks
COSC 2336: Data Structures and Algorithms Fall 2020
• More practice with recursion.
• Practice writing some template functions.
• Use stack ADT to implement given algorithms.
• Practice using Stack class container given as a library in a separate file. • Look at some common applications of stacks.
Description
In this assignment, you will be using the Stack abstract data type we developed for this unit and discussed in our lectures, to implement 4 functions that use a stack data type to accomplish their algorithms. The functions range from relatively simple, straight forward use of a stack, to a bit more complex. But in all 4 cases, you should only need to use the abstract stack interface functions push(), pop(), top(), and isEmpty() in order to successfully use our Stack type for this assignment and the function you are asked to write.
NOTE
You are to use the Stack ADT abstraction give to you for this assignment. If you are familiar with STL stack containers, you are not to use them for this assignment. Part of the assignment is to look over and learn the Stack ADT implementation we give you here based on our textbook Stack examples.
Setup
For this assignment you will be given the following files:
File Name
assg09-tests.cpp assg09-stackfun.hpp assg09-stackfun.cpp Stack.hpp
Stack.cpp
Description
Unit tests for the member functions
you are to write.
Header file where function prototypes for the functions you write using stacks should go. Implementaiton file, the implementation of the 4 functions you write for this assignment go here. Header file defining a Stack ADT for use in implementing the functions for this assignment. You will not make any modifications in this file, you are only going to be using the given Stack. Implementation file for the Stack ADT
template class. You also do not make any changes in this file either.
Set up a multi-file project to compile the .cpp source files and run them as shown for the class. The Makefile you were given should be usable to create a build project using the Atom editor as required in this class. You will only be adding code to the assg09-stackfun.[hpp|cpp] file in this assignment. The Stack.[hpp|cpp] file contains a Stack container. You are to use this Stack ADT for the 4 functions you are to write for this assignment.
1
The general approach you should take for this assignment, and all assignment is:
Set up your project with the given starting code. The files should compile and run, but either no tests will be run, or tests will run but be failing.
For this project, start by uncommenting the first TEST_CASE in the assg09-tests.cpp file. These are the unit tests to test the functionality of your doParenthesisMatch() function, the member function you are to implement.
AddthecorrectfunctionprototypeforthedoParenthesisMatch()memberfunctionintheassg09-stackfun.hpp header file. The prototyp.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Thesis Statement for students diagnonsed withADHD.ppt
ECET 370 Exceptional Education - snaptutorial.com
1. ECET 370 Week 1 Lab 1
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled
“User-defined 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
2. 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 1 Lab 1
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, 4, and 5 use the programs in DocSharinglabeled
“User-defined 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.
3. 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 Lab 2
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, and 3 use the programs in DocSharinglabeled “User-
defined array list."
4. 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
5. 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 Lab 3 Linked Lists
For more classes visit
www.snaptutorial.com
General Instructions
Exercises 1, 2, and 3 use the programs in DocSharinglabeled “User-
defined 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
6. 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 Lab 4 Complexity of
Computational Problems
For more classes visit
www.snaptutorial.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
7. “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 Lab 5 Search Algorithms and
Techniques
For more classes visit
www.snaptutorial.com
General Instructions
8. 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.
9. *******************************************************
ECET 370 Week 7 Lab 7 Binary Trees
For more classes visit
www.snaptutorial.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.
html.
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.
**********************************************************************************