Runtime and logical errors
-
We can only do a linear search on an unsorted array, but on a sorted array we can do a binary search. In this chapter we will study two different algorithms for searching, linear search and binary search. In linear search we look through an unordered list until we find the item we are looking for. The length of time it takes to look up something using a linear search will depend upon the size of the list. Imagine trying to look up a name in a telephone directory if it was not alphabetized (sorted). If we were to use...
9p linhtk93 15-04-2013 52 3 Download
-
I have noticed over the years that students have great deal of difficulty dealing with composite and abstract data types. Therefore we are going spend an extra lab review material we have already learned. Vector data type, a variation of array, will be introduced as well. Vector data type (Vector Class) can be used when you need an array that grows dynamically. However, C++ does not allow us to declare size of an array dynamically like some other languages. It is important for you to declare the maximum size you will need. Suppose you are writing a program to keep...
7p linhtk93 15-04-2013 57 2 Download
-
Dr. John P. Abraham, Professor Until now we have talked about variables that hold values of differing data types. For example: int x =20; The memory location referenced by x has a value of 20. float y=21.22; The memory location referenced by y has a value of 21.22. In early chapters we discussed that a variable name is an alias for a memory address. What if we wanted to know the address of the memory location where the inter variable x that has a value of 20 is stored? We can use the address operator &x to do that....
5p linhtk93 15-04-2013 55 2 Download
-
When instructions within a program are executed one after the other sequentially that program is said to have a linear structure. Decision making after examining all available options is very important in life as well as in programming. For example, it is the law that all males 18 or older should register with the selective service. If you are writing a program to send out reminders to enforce this law, the decision to send the letter should be based on if a person is male and if he is 18 or older. In this chapter you will learn how to...
8p linhtk93 15-04-2013 83 2 Download