You are on page 1of 3

Computing

CS151:
INTRODUCTION TO
COMPUTING

Computational thinking is a fundamental skill for everyone,


not just for Computer Scientists
Computing is everywhere
Computing is fun
Computing is about solving problems
Computing is useful
Allows us to help people, communicate, make an impact

Computing is a new tool


Gone in a short period of time from inaccessible to accessible to
everybody, including young children
A LOT of room for innovation
1

Programs

E.g. The case of Google

Algorithms
Have you heard the term algorithm?
Where?

A program is a set of instructions that a


computer follows to perform a task.
Programs are commonly referred to as
software.

What is an algorithm?

What software have you


used?

Computers operate by following a list of instructions set


for them

An algorithm is a set of instructions for completing a task


how we get computers to solve problems

Exercise: Moving the Robot

A Few Solutions:

Your task: Move the robot to the GOAL square


You can only use the following instructions:

1.

Right
Right
Right
Up
Up
Up

2.

Right
Up
Right
Right
Up
Up

3.

Right
Up
Right
Up
Right
Up

4.

Up
Up
Up
Right
Right
Right

LEFT, RIGHT, UP, DOWN


(Each one moves the robot one step in the given direction)

GOAL

Robot

Algorithms

Exercise: Searching

Is there a single way to achieve a task like


Moving the Robot?

Class exercise using card numbers

There can be more then one algorithm for a task or


problem (and usually there is more than one)
Some algorithms are faster than others
Many of the algorithms that have been discovered have
made it possible to solve problems that previously took
an infeasible length of time
Finding all pages that contain your name on the WorldWide Web

Goal: Students end up using two common


searching algorithms: Linear Search and
Binary Search

Searching

Linear Search

Computers are often required to find


information in large collections of data.
They need to develop quick and efficient ways of
doing this.
Several search methods have been developed in
the Computing field
Linear Search
Binary Search

In computer science, linear search or sequential


search is a method for finding a particular value
in a list, that consists of checking every one of
its elements, one at a time and in sequence,
until the desired one is found.

Binary Search

Linear Search vs. Binary Search

In computer science, a binary search algorithm


finds the position of a specified value within a
sorted list.
In each step, the algorithm compares the desired
value with the value of the middle element of
the list.
If they match, then the desired value has been found
Otherwise, if the desired value is less than the middle
element's value, then the algorithm repeats its action
on the sub-list to the left of the middle element or, if
the input key is greater, on the sub-list to the right.

10

Linear search is simpler than binary search


Linear search is slower than binary search
Linear search is useful for short list (less than 100
items)
Binary search is useful for both short and large
list

11

12

You might also like