0% found this document useful (0 votes)
68 views26 pages

U20Est109 / Problem Solving Approach L N D C S E

This document outlines the syllabus for a course on problem solving approaches. The course objectives are to teach key concepts of computational thinking, problem solving, algorithms, data organization, fundamental algorithms, factoring methods, arrays, sorting, searching, text processing, pattern searching, and recursive algorithms. The syllabus covers these topics over 5 units. Unit 1 introduces computational thinking, information, data types, logic, and limits of computation. Unit 2 covers algorithmic thinking and data organization. Unit 3 discusses fundamental algorithms and factoring methods. Unit 4 focuses on arrays, merging, sorting, and searching. Unit 5 is on text processing, pattern searching, and recursive algorithms.

Uploaded by

Yekanthavasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views26 pages

U20Est109 / Problem Solving Approach L N D C S E

This document outlines the syllabus for a course on problem solving approaches. The course objectives are to teach key concepts of computational thinking, problem solving, algorithms, data organization, fundamental algorithms, factoring methods, arrays, sorting, searching, text processing, pattern searching, and recursive algorithms. The syllabus covers these topics over 5 units. Unit 1 introduces computational thinking, information, data types, logic, and limits of computation. Unit 2 covers algorithmic thinking and data organization. Unit 3 discusses fundamental algorithms and factoring methods. Unit 4 focuses on arrays, merging, sorting, and searching. Unit 5 is on text processing, pattern searching, and recursive algorithms.

Uploaded by

Yekanthavasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

U20EST109 - Problem Solving Approach

U20EST109 / PROBLEM SOLVING APPROACH LECTURE NOTES


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SEMESTER: I YEAR: Jan 2020 – April 2020

De part me nt of Comput er sc ie nc e and Engine e ring Page 1


U20EST109 - Problem Solving Approach

Syllabus:

L T P C Hrs
U20EST109 PROBLEM SOLVING APPROACH
3 0 0 3 45
(Common to CSE,IT,CCE)

Course Objectives
 To identify the key concepts of computational thinking and problem solving.
 To know the basics of algorithm and data organization.
 To understand the fundamental algorithms and factoring methods.
 To know the basic concepts of array and problem solving techniques.
 To familiarize the concepts of text processing, pattern searching and
recursive algorithms.

Course Outcomes
After completion of the course, the students will be able to
CO1 - Explain the basic concepts of computational thinking and problem solving. (K2)
CO2 - Explain basic concepts of algorithm and data organization. (K2)
CO3 - Illustrate algorithmic solution to problem solving. (K3)
CO4 - Explain the concepts of array, merging, sorting & searching.
(K2) CO5 - Implement recursive algorithm to solve problems. (K3)

UNIT I INTRODUCTION (9 Hrs)


Computational Thinking - Information and Data - Converting Information into Data – Data
Capacity – Data Types and Encoding – Logic-Solving Problems – Limits of Computation –
Pseudocode and Flow Chart.

UNIT II ALGORITHMIC THINKING & DATA ORGANIZATION (9 Hrs)


Algorithmic Thinking: Algorithms – Software and Programming Languages – Actions. Data
Organization: Name list, Graph Hierarchies – Spread Sheets – Text processing – Patterns –
Pseudocode and Flow Chart.

UNIT III FUNDAMENTAL ALGORITHMS & FACTORING METHOD (9 Hrs)


Fundamental Algorithms: Exchanging – Counting – Summing – Factorial Computation –
Fibonacci Sequence – Reversing the Digit-Base Conversion – Character to number
conversion. Factoring Methods: Finding Square Root – Greatest Common Divisor – Prime
Number – Prime Factor – Pseudocode and Flow Chart.

UNIT IV ARRAY, MERGING, SORTING AND SEARCHING (9 Hrs)


Array Techniques: Introduction – Array order reversal – Array Counting or Histogramming
– Maximum and Minimum of a Set – Removal of Duplicate – Partitioning – Longest
monotone. Sorting and searching: Sorting by Bubble, Selection, Insertion. Searching: Linear,
Binary – Pseudocode and Flow Chart.

UNIT V TEXT PROCESSING, PATTERN SEARCHING & RECURSIVE

De part me nt of Comput er sc ie nc e and Engine e ring Page 2


ALGORITHM (9 Hrs)
Key word Searching – Text Line Adjustment – Linear Pattern Search – Sub Linear Pattern
Search. Recursion: Towers of Hanoi – Sample Generation – Combination Generation –
Permutation Generation – Pseudocode and Flow Chart.

Text Books
1. David Riley and Kenny Hunt, ―Computational Thinking for Modern Problem
Solver‖, Chapman & Hall / CRC Textbooks in Computing, 2014.
2. R. G.Dromey, ―How to solve it by Computer‖, PHI, 2008.
3. Vickers Paul, ―How to Think like a Programmer: Problem Solving for the
Bewildered‖, Cengage Learning EMEA, 2008.

Reference Books
1. V. Anton Spraul, ―Think Like a Programmer: An Introduction to Creative
Problem Solving‖, Cengage
Learning EMEA, 2012.
2. Harold Abelson & Gerald Jay Sussman, ―Structure and Interpretation of
Computer Programs‖, McGraw- Hill Book Company, 1997.
3. Don McAdam, Roger Winn,‖ A Problem-Solving Approach‖, Prentice Hall Canada; 2nd
Edition.
4. Kathryn Rentz, Paula Lentz, ―A Problem-solving Approach ―, McGraw-Hill
Education, 2018.
5. Sham Tickoo ―A Problem-solving Approach‖, Delmar / Cengage Learning, 2009.

Web References
1. https://www.edx.org/learn/problem-solving
2. https://www.lynda.com/Business-Skills-tutorials/Problem-Solving-Techniques/553700-
2.html
3. https://www.classcentral.com/course/problem-solving-skills-6687
UNIT - I

INTRODUCTION (9 Hrs)
Computational Thinking - Information and Data - Converting Information into Data – Data
Capacity – Data Types and Encoding – Logic-Solving Problems – Limits of Computation –
Pseudocode and Flow Chart.

PART A (2 marks)
1. Define Computational Thinking
It represents a universally applicable attitude and skill set everyone, not just computer
scientists, should be eager to learn and use.
Apart from desktop computers, laptop computers, and tablet computers, many other of
today’s devices rely upon embedded computers. Traction control, antilock brakes, computer-
assisted parking, and even car repair all involve computers on board automobiles. Digital
cameras are little more than a computer with a lens attached and most cell phones are really just
handheld computers.

2. Define Data.
―The quantities, characters, or symbols on which operations are performed by computers
and other automatic equipment, and which may be stored or transmitted in the form of electrical
signals, records on magnetic tape or punched cards, etc.‖
Denote an encoding of information such that the information can manipulated by a
computing system.

3. Define
Information.
Information:
―Knowledge communicated concerning some particular fact, subject, or event; that
of which one is apprised or told; intelligence, news‖
Information is ―that which is obtained by the processing of data.‖

4. Difference between discrete data and continuous data.


Data is continuous if there are an infinite number of possible values for an individual
datum, whereas data is discrete if there are a finite number of possible values.
Continuous data is usually associated with measurements involving the physical or real
world, whereas discrete data is usually associated with things that can be counted.

5. Difference between digital and analog data.


An analog signal is an encoding of continuous data, whereas a digital signal is an
encoding of discrete data. In earlier times, electronics were systems that processed analog
signals, but modern computing systems almost exclusively utilize digital electronics. The
reason that digital systems are generally preferred to analog systems is that there are a finite
set of possible values to process in a digital system.
In digital systems, the smallest unit of data is known as a binary digit, or bit. At any point
in time, a bit can only take on one of two possible values: ON or OFF.
6. Define bit string.
A sequence of bits is commonly referred to as a bit string. Since the bits in the string are
able to vary in the values that they hold, some bits being 1 while other bits are 0, a bit string
is able to display a great number of different patterns.

7. Define data capacity.


The data capacity of a computing system is the amount of information that can be
encoded by the system. Since the data capacity is directly related to the number of bits that
are available on the system, the data capacity is simply a count of the number of bits.
Data capacity is not usually based on a direct count of the number of bits, but rather is
based on the unit of measure known as a byte. A byte is a bit string of length eight. A single
byte, therefore, is able to store 28 or 256 unique patterns.

8. Define Positional Number systems.


A positional numeral system must first specify a base, also known as the radix that
describes how many digits exist in that particular system. In the decimal numeral system, for
example, the base is 10 since it uses the 10 digits 0 through 9.
The smallest digit of a positional numeral system is always zero while the largest digit is
always one less than the base.

9. What is called Precision?


Precision is a measure of the accuracy of a stored quantity. The precision is usually
measured as the number of available bits. If a computer uses 16 bits to store real numbers, we
say that the computer is precise up to 16 bits, or that the computer uses 16 bit precision.

10. What is called underflow and overflow?


Overflow occurs when a computer instruction produces a value that is too large to be
encoded by the number of bits available.
Underflow occurs when a computer instruction produces a value that is too small in
magnitude (i.e., very close to zero) to be encoded by the number of bits available.

11. Define Sound.


Sound is a physical phenomenon caused by waveforms that propagate through the air. A
microphone is used to transform the waveform into an analog electric signal after which the
analog signal is sampled to produce a digital encoding.
Sampling is a process where the strength of a changing signal is measured at regular time
intervals and those measurements are then recorded. In this way, the sound wave is converted
into a sequence of numeric values.

12. Define Frequency.


Frequency is the rate at which sound waves change and is measured in terms of the hertz.
The hertz is denoted as Hz and is defined as the number of cycles (or changes) per second.
Sound waves that change at a slow rate are perceived as a low pitch while sound waves
that change at a high rate are perceived as higher in pitch. The average person can hear sound
waves 20 Hz up through about 20,000 Hz or 20 kHz.
13. Define Logic.
Logic, in its broadest sense, deals with correct and incorrect ways to reason. Logic
provides a way to tell the difference between incorrect and correct thinking, and can
therefore be defined as the science of correct thinking. The study of logic can be broken into
two categories: inductive logic and deductive logic.

14. Difference between Deductive Logic and Inductive Logic.


Inductive logic is a type of reasoning that begins with a set of observations or
experiences from which conclusions can be derived with some degree of certainty. As an
example of inductive reasoning, consider a scenario where you have eaten brussels sprouts
only twice in your life.
Deductive logic, by contrast, begins by assuming that certain things are absolutely true
from which other facts must also be absolutely true. Any conclusions that are reached under
deductive logic are absolutely, irrefutably, and certainly true if the assumptions are true.

15. Draw the truth table for Logical conjunction.

16. Draw the truth table for Logical disjunction.

17. Difference between tautology and contradiction.


Any proposition that has a value of True regardless of the inputs is said to be a tautology.
Any proposition that has a value of False for all inputs is said to be a contradiction.
Tautologies and contradictions should be avoided when writing propositions and they
should also be avoided in the normal course of human conversations since such statements do
not express any sort of productive line of reasoning. The following propositions give
examples of a tautology and a contradiction.
Tautology: P or not P
Contradiction: P and not
P
18. List the limitations of Computation.
 How Is Capacity Measured In Computers?
 An Estimate Of The Physical Limitations
 Benchmarks
 Counting The Performance
 Impractical Algorithms
 Impossible Algorithms
 Metaphysical Limitations

PART B (5 marks)
1. How to Convert Information into Data.
 There are two different types of data: continuous and discrete.
 Data is continuous if there are an infinite number of possible values for an individual
datum, whereas data is discrete if there are a finite number of possible values.
 Continuous data is usually associated with measurements involving the physical or
real world, whereas discrete data is usually associated with things that can be
counted.
 As an example, consider measuring the weight of an orange. Although the orange
could weigh exactly 200 grams, it might also weigh 229.3 grams or 229.31533 grams
or even 229.31533480185993 grams.
 In other words, the weight of an orange is an example of continuous data since there
are an infinite number of possible values that might describe the weight of an orange.
On the other hand, consider asking your friends how many biological parents they
have who are still living.
 A sequence of bits is commonly referred to as a bit string. Since the bits in the string
are able to vary in the values that they hold, some bits being 1 while other bits are 0, a
bit string is able to display a great number of different patterns.

 Consider encoding all of the symbols on a keyboard; including letters, digits, and
punctuation symbols.
 We would make a list of every possible keyboard symbol and then begin to associate
each symbol with a unique bit string pattern.
 We might, for example, associate the letter A with the 8 bit string 01000001 and a
period with the 8 bit string 00101110.
 Consider, however, a string of two lightbulbs. How many different patterns could the
string exhibit? Two of the patterns are obvious: both lightbulbs could be 0 or both
lightbulbs could be 1. Two other patterns are also possible

The four patterns that a string of two bits can exhibit are 00, 01, 10, and 11.

2. Write short notes on Data Capacity.


 Data encoding requires us to know how many bits are required to store a piece of
information.
 When storing the symbols on a keyboard, for example, we must know how many bits
would be required to store any one of the symbols.
 In general, the number of bits required to store a piece of information is proportional to
the number of values that the information may take.
 A single day of the week can be encoded as a bit string of length three since there are
seven days in a week and there are eight patterns available.
 A single month of the year can be stored in a bit string of length four since there are 12
months in a year and 16 patterns available.
 Information that involves a large set of possible values will therefore require longer bit
strings to encode while information of little content can be encoded in shorter bit strings.
 The data capacity of a computing system is the amount of information that can be
encoded by the system.
 A byte is a bit string of length eight. A single byte, therefore, is able to store 28 or 256
unique patterns.
 A word, which is a unit of data capacity that is based on the hardware of a computing
system. A word is a fixed-length sequence of bits that are processed as a single item by
the processor.

The approximate number of bits required to store various types of information.


 The most common prefixes and their meaning as both a power of 2 and an approximate
decimal value.
Data capacity prefixes.
 The data capacity required by various types of information varies since the richness of the
information content varies by type. Figure shows how much data capacity is required to
store certain types of information

Amount of memory required to store certain types of information

3. Describe in detail about the Limits of Computation.


 How Is Capacity Measured In Computers?
 An Estimate Of The Physical Limitations
 Benchmarks
 Counting The Performance
 Impractical Algorithms
 Impossible Algorithms
 Metaphysical Limitations

How Is Capacity Measured In Computers?


 The question of capacity is thought of as a two-part question: (1) how to measure
processing speed and (2) how to measure storage size. Computer scientists know this as
an issue of time and space.

An Estimate of the Physical Limitations


 Modern computers are mostly constructed from electronic components. These devices
have followed Moore’s law primarily due to miniaturization. As electrical circuits have
become smaller, they also have become faster.
 The particular kind of technology that has fueled this miniaturization is semiconductors.
Semiconductor components store and manipulate electrons, and those electrons flow
from one component to another on narrow paths.
 There are at least three other technologies that have been considered as future ways to
fabricate computers:
o 1. Optical computers
o 2. Biological computers
o 3. Quantum computers
Benchmarks
 The empirical approach is similar to using a stopwatch to time a track runner, except the
thing you are timing is a computer application running on some particular computer.
Such an application timing is known as a benchmark.
 Sometimes benchmarks are used to determine such things as
o Response time—How quickly does the application respond to user input?
o User friendliness—How easy is the application to use?
o Robustness—How immune to failure is the software?

Counting the Performance


 Computer scientists have a name for algorithms that perform according to a direct
proportion; they are called linear algorithms.
Impractical Algorithms
 All of the algorithms examined in the previous section can be described as having a
polynomial performance, because each formula for counting in terms of the number of
data items (N) is a polynomial. Broadly speaking, polynomial algorithms are considered
to be appropriate computations for computers.
Impossible Algorithms
 Computer scientists use a classic example known as the halting problem to illustrate
impossible algorithms.
 To understand the halting problem it is important to observe that some algorithms will
execute forever, assuming there is no manual interruption. For example, consider the
following while instruction:

HaltChecker
Metaphysical Limitations
 The concept that Turing proposed has become well known as the Turing test. The goal of
the Turing test is determine whether a computing system is intelligent.

A Venn diagram of human behavior and

intelligence PART C (10 marks)


1. Describe in detail about data types and its encoding techniques.
 Numbers
 Numeral Systems
 Positional Numeral System
 Integers as Binary Bit Strings
 Real Numbers as Binary Bit Strings
 Precision as a Source of Error
 Underflow and Overflow as Sources of Error
 Text
 Colors
 Pictures
 Sound
Numbers:
Numeral Systems:
 A numeral system is a way of representing numbers in written form. Consider, for
example, the three numbers shown in Figure.
 If these markings are interpreted using the numeral system known as tally marking, they
correspond to the numbers one, two, and three.
 Under tally marking, a number is represented by making one tally mark for each unit in
the number.
 If these markings are interpreted using the Roman numeral system, they also correspond
to the numbers one, two, and three.
 If these markings are interpreted using the decimal numeral system, they correspond to
the numbers one, eleven, and one hundred and eleven

Three numbers
 Figure shows how the number five is represented in each of these four numeral systems:
tally marking, the Roman numeral system, the decimal system, and the binary system.

Four representations of the number five


Positional Numeral System:
 A positional numeral system must first specify a base, also known as the radix that
describes how many digits exist in that particular system. In the decimal numeral system,
for example, the base is 10 since it uses the 10 digits 0 through 9.
 As an example consider the hexadecimal system, which uses the symbol A to denote the
value 10, the symbol B to denote the value 11, and onward through F to denote the value
15.

Common positional numbering systems


 The number 925 is understood as (9 × 102) + (2 × 101) + (5 × 100) and since any positive
integer that is raised to the 0th power is equal to 1 this reduces to (9 × 100) + (2 × 10) +
(5 × 1).

Example of using the decimal numeral system


 The most common powers of ten have names that allow us to more easily describe
decimal numbers. These names are shown in Figure.

Common names given to various powers of 10


 The subscript in 10110 indicates that the number is expressed in the decimal system,
whereas 10116 is a number that is expressed using a base of 16 and 1012 is a number that
is expressed in binary.
 Consider, for example, the two numbers 10110 and 1012 as shown in Figures 1.13 and
1.14, respectively. The number 10110 has the value one hundred and one while the
binary number 1012 does not.
 Since the radix is 2 we understand this to mean (1 × 22) + (0 × 21) + (1 × 20) which is
equal in the decimal system, to 4 + 0 + 1, or 5.
Interpretation of 10110
Integers as Binary Bit Strings:
 Computing systems represent integer numbers as binary bit strings.
 The binary system is a fitting choice for computers because there are only two
values in the binary system and hence a single bit has sufficient data capacity to
store a single binary digit.

Understanding binary bit strings


Real Numbers as Binary Bit Strings:
 In base 10 the value 1.625 means (1 × 100) + (6 × 10–1) + (2 × 10–2) + (5 × 10–3). We can
then represent real numbers as binary bit strings assuming that we can determine the decimal
location. Consider, for example, the meaning of 1.1012.

Precision as a Source of Error :


 Precision is a measure of the accuracy of a stored quantity. The precision is usually
measured as the number of available bits.
 If a computer uses 16 bits to store real numbers, we say that the computer is precise up
to 16 bits, or that the computer uses 16 bit precision.
Underflow and Overflow as Sources of Error:
 Overflow occurs when a computer instruction produces a value that is too large to be
encoded by the number of bits available.
 Underflow occurs when a computer instruction produces a value that is too small in
magnitude (i.e., very close to zero) to be encoded by the number of bits available.
Text:
 All data that is stored in a computing system is encoded as bit strings.
 Textual characters are usually encoded as integer values using the encoding schemes
 The associations between numbers and text are known collectively as a character
encoding scheme.
 The most common character encoding scheme is the ASCII table which defines
associations between numbers and English textual characters.
 In the ASCII table, the number 65 is associated with uppercase A, whereas the number 97
is associated with lowercase a. The number 38 is associated with the ampersand (&) and
the number 126 is associated with the tilde (~).
Colors:
 The human eye perceives color through three types of biological photo sensors known as
cones. Each cone is attuned to one of three wavelengths that correspond roughly to red,
green, and blue light.
 The RGB color model is the most common way of representing color in image-processing
systems. The RGB model uses red (R), green (G), and blue (B) as the primary colors such
that any color can be created by combining different amounts of these three primaries.

How colors are typically encoded as binary bit strings


Pictures
 The most common encoding of a digital image is that of a two-dimensional grid of colors.
Each element of the grid is known as a pixel (this term is an abbreviation of the phrase
―picture element‖) and represents a very small rectangular region of the image that is
comprised of a single color.
 Figure shows a black-and-white image having eight columns and eight rows for a total of
64 pixels. Since there are only two colors, we use a single bit to encode a color.
 More specifically, the image pixels could be encoded as the bit string
00111100010000101010010 11000000110100101100110010100001000111100.

A black-and-white image could be encoded using the bits shown on the right.
Sound
 Digital audio is used almost exclusively today when recording, processing, and
distributing sound.
 Sound is a physical phenomenon caused by waveforms that propagate through the air.
 A microphone is used to transform the waveform into an analog electric signal after
which the analog signal is sampled to produce a digital encoding.
 Sampling is a process where the strength of a changing signal is measured at regular
time intervals and those measurements are then recorded.
 Frequency is the rate at which sound waves change and is measured in terms of the hertz.
The hertz is denoted as Hz and is defined as the number of cycles (or changes) per
second.

2. Describe in detail about Logics.


 Logic:
 Boolean Logic:
 Writing Well-Formed Propositions
 Evaluating Propositions
 Conjunction (AND)
 Disjunction (OR)
 Implication (IMPLIES)
 Equivalence (≡)
 Logical Negation (NOT)
 Compound Propositions
 Logical Equivalence
 Tautologies and Contradictions

Logic:
 Logic, in its broadest sense, deals with correct and incorrect ways to reason.
 Logic provides a way to tell the difference between incorrect and correct thinking, and
can therefore be defined as the science of correct thinking.
 The study of logic can be broken into two categories:
o inductive logic
o deductive logic
 Inductive logic is a type of reasoning that begins with a set of observations or experiences
from which conclusions can be derived with some degree of certainty.
 Deductive logic, by contrast, begins by assuming that certain things are absolutely true
from which other facts must also be absolutely true.
 A premise is a statement that is assumed to be true and that is used to justify a
conclusion.
 A conclusion is a statement of truth that must logically flow from the premises.
 A syllogism as a logical argument that contained two premises and a true conclusion that
must logically follow if the two premises are actually true.
 Symbolic logic is a modern extension of Aristotelian logic where symbols, rather than
phrases drawn from human language, are used to represent statements of truth.

Boolean Logic:
 form the basic units of Boolean logic. A proposition is a statement that can be either true
or false. Stated another way, a proposition is a statement that has a value of either true or
false.
 In Boolean logic there are only two values: true and false. These two values are known as
logical values or truth values. Boolean logic does not allow for uncertainties or for
probabilities
 Propositions can be either
o simple
o compound
 A simple proposition is one that cannot be broken into parts.
 A compound proposition is formed by combining simple propositions with logical
connectives, also known as logical operators.
 There are four fundamental logical operators that are best described by the words
o and
o or
o implies
o not
Writing Well-Formed Propositions
 Propositions must be well formed (i.e., properly written) to have meaning.
 A well-formed logical proposition should follow specific rules.
Rule 1 - Each of the following is a simple proposition.
a. Any single letter
b. True
c. False

Rule 2—Let a box (□) stand for a proposition (either simple or compound).
 Our process of reasoning will move from the simplest substructures within the entire
proposition up to the more complex propositions that comprise the whole.
Step 1- We can first apply Rule 1a to the capital letters P, Q, and R.
Step 2- By applying Rule 1a to each of the letters P, Q, and R we can rewrite the
expression as shown next.
Step 3 - We must now see if any further rules can be applied to what remains of the
expression.
Step 4- We must continue to find further rules to apply to what remains of the expression.
Step 5- We now notice that we can replace ―not □‖ with a box since ―not □‖ is
a proposition as defined by Rule 2e.
Step 6- Finally, it should be obvious that Rule 2a can be applied to complete our proof.
We can replace ―□ and □‖ with a box to yield.

The Boolean proposition “P and not (Q or R)” is shown to be well formed such that each
dotted box corresponds to some proposition that is an element of the whole.

Evaluating Propositions
 When we evaluate a proposition, the goal is not to make sure that it is well written but
rather to determine the truth value of the proposition. Consider, for example, the
following simple propositions.
P = ―I am hungry.‖
Q = ―I am cold.‖
 Operators that have an arity of two are known as binary operators and operators that
have an arity of one are known as unary operators.

The logical operators


Conjunction (AND)
 For the binary operators there are only two inputs and since each of these two inputs has only
two possible values there are only four situations that the operator must handle.

Disjunction (OR)
 Logical disjunction, however, is not as intuitive since our informal use of the word or is not
as closely connected to the way it is formally defined. We often pose two mutually exclusive
possibilities and ask which of those two possibilities actually occurred.

Implication (IMPLIES)
 Logical implication is perhaps the most challenging operator to master. This
operator captures the idea that if one thing is true, then some other thing must also, by
logical necessity, be true.

Equivalence (≡)
 Variables P and Q are said to be equivalent if they have the same truth value. The truth
table for logical equivalence is given in Figure

Logical Negation (NOT)


 Logical negation is the only unary operator. This operator expresses the obvious thought
that if something is not true then it must be False, and if something is not False then it must be
True

Compound Propositions
 When we evaluate a proposition, the goal is to determine the truth value of the proposition.
 To construct a truth table for some proposition you must do the following.
o Make a list of each logical variable (abbreviation) that appears in the proposition. If
one variable occurs more than once in the proposition, it should be included only
once in your list.
o Place a column in the truth table for every variable list your list. The column heading
should be the variable itself.
o For the heading of the last column you should write the entire proposition.
o If there are N variables in your list, you must create 2N rows. Each row represents a
unique combination of values for the N variables.
o For each row, determine the value of the proposition and place that value in the last
column.

Logical Equivalence
 Two propositions are said to be equivalent if they have the same truth table. Consider, for
example, the two propositions
not (P and Q)
(not P) or (not
Q)

Two different propositions have the same truth table. These two propositions are therefore
said to be equivalent.
Tautologies and Contradictions
 Any proposition that has a value of True regardless of the inputs is said to be a
tautology. Any proposition that has a value of False for all inputs is said to be a
contradiction.

3. Examine the characteristics of good problem solving techniques.


The modern style of problem solving:
1. Problem definition
2. Logical reasoning
3. Decomposition
4. Abstraction
Problem Definition:
 Software engineers recognize at least three major phases to the process of developing
software:
1. Analysis
2. Design
3. Implementation
 Requirements are further divided into two types:
o (1) Functional requirements to specify the particular task(s) the software must
perform and
o (2) Nonfunctional requirements to define other characteristics and constraints related
to the software. Nonfunctional requirements include expectations for things like
reliability, safety, security, performance, delivery, and help facilities.
 A good list of functional requirements must be
o Clear
o Consistent
o Complete

A state-activity table for the video player app


Logical Reasoning:
 The second of the four important problem-solving strategies for a computer scientist is
logical reasoning.
 Cause-effect relationships: A cause-effect relationship consists of a logical condition (the
cause) that forces the program to perform some task (the effect).

Some typical cause-effect relations from programs


 Many software designs use the idea of separating an algorithm into three components:
o 1. Software for communicating with the user
o 2. Software for retrieving and storing data
o 3. Software for calculating results based on user input and/or retrieved data

Decomposition: Software Design


 Decomposition techniques are often called divide and conquer strategies. The idea is to
approach a single problem by separating (dividing) it into its constituent subproblems,
and then to solve (conquer) each subproblem individually, as depicted in Figure

Divide and conquer means to separate a problem into subproblems.


 the larger problem of making a pizza can be thought of as a collection of
six subproblems:
o (1) making a crust,
o (2) making and spreading sauce,
o (3) spreading cheese,
o (4) spreading toppings,
o (5) baking,
o (6) slicing.

Decomposing the problem of making a pizza


 Another form of software design that is widely used by software engineers today is known as
successive prototyping. A prototype of any object is an early approximation of the object.
 A reasonable succession of prototypes might continue as indicated next:
o Prototype 1—Initial web page only (see Figure 4.12)
o Prototype 2—Same as Prototype 1 except incorporating Sal’s requested
improvements
o Prototype 3—Same as Prototype 2 except including all inventory pages (no ability
to modify cart)
Initial page for SSS online purchase website
Abstraction: Class Diagrams
 Abstraction is anything that allows us to concentrate on important characteristics while
deemphasizing less important, perhaps distracting, details.
 A control structure is a mechanism for specifying the proper order in which instructions
must be performed. Algorithms are composed of five fundamental control structures:
o 1. Sequential control
o 2. Selection
o 3. Repetition
o 4. Control abstraction
o 5. Concurrency
 Data abstraction is no less important than control abstraction. A standard way to
diagram data abstraction is known as a class diagram.
 The class diagram rectangle abstracts the group of objects in terms of two things:
o Attributes
o Operations

Thermostat class diagram


Abstraction: Use Case Diagrams
 Use case diagrams are a technique for depicting a system—software system or some
other system—by way of interaction between computer users and a system.
 The two main components of a use case diagram are actors and use cases.

Cab driver use case diagram


 An «extend» relationship occurs whenever one action is an extension or specialized
version of another.
 An «include» relationship results from one action making use of another as part of its
function.

Grocery store use case diagram

You might also like