0% found this document useful (0 votes)
64 views

Big O Notation, Programming Paradigms

The document discusses big O notation and programming paradigms. Big O notation defines time complexity of algorithms, including O(1) constant time, O(n) linear time, and O(n^2) quadratic time. Imperative programming uses commands to specify what the computer must do, while declarative programming focuses on desired results. Object-oriented programming structures code into reusable classes and objects using principles like encapsulation, inheritance, and polymorphism.

Uploaded by

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

Big O Notation, Programming Paradigms

The document discusses big O notation and programming paradigms. Big O notation defines time complexity of algorithms, including O(1) constant time, O(n) linear time, and O(n^2) quadratic time. Imperative programming uses commands to specify what the computer must do, while declarative programming focuses on desired results. Object-oriented programming structures code into reusable classes and objects using principles like encapsulation, inheritance, and polymorphism.

Uploaded by

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

BIG O NOTATION

The big O notation also known as the time complexity defines the longest time it can take to perform an
operation. Some common complexities include:

The O(1) complexity – Constant time complexity: This is used when you try to access a value with its
index in an array.

The O(n) – Linear time complexity: This is used when inserting an item into a hash table, or in real life,
reading book with a number of pages, simple search. Here, time increases s input increases.

O(log n) – Logarithmic time complexity: Binary search in a sorted array. As input size grows, operation
time increases slowly in a linear manner.

O(n^2) – Quadratic time complexity: This is using nested array.

Programming Paradigms.

It refers to a way of solving problems using the features available in a particular programming language,
i.e. the style of programming.

The Imperative Programming Paradigm

This uses the imperative mood which involves making a command or a request. It uses a series of
command which specify what the computer had to do, and when, in order to achieve a desired result e.g
Java, Basic, Fortran, Assembler etc Here, we'll be seeing concepts like procedural programming and
object-oriented programming.

The Declarative Programming Paradigm

This focuses more on what a program should accomplish and less on how to go about it. It describes
their desired results without texting the commands that must be performed. It may seem like magic but
there's a lot of work going on under the hood. Here, concepts involved include the functional
programming concept, eg furniture assembly. While imperative programming provides for assembly,
declarative programming provides a picture of the finished piece of furniture as a template. the
integrative functional programming concept for example for assembly instructions for assembly
instructions for assembly declarative programming provides a picture of the finished piece of furniture
as a template so let's take the example again so when you're trying to assemble furniture imperative
programming would say okay I have to go through this particular steps and so on but the declarative
programming paradigm would give you a picture of the finished piece of furniture as a template to work
with. Most modern language support both paradigms to an extent but let's talk a bit more about
procedural programming. Procedural programming follows a simple step-by-step approach to creating
software. Each procedure is usually a function or a set of functions. Languages that follow procedural
concepts include Pascal, Fortran and the rest of them. for example an application to use a library when
written in procedural programming formats would look like:
function register () {}

function addBook () {}

function removeBook () {}

function findBook () {}

function borrowBook () {}

function returnBook () {}

So generally these are the steps involved in using a library. so that is how the procedural programming
concepts would list it out for you.

Advantages of Procedural Programming:

- Very useful in general-purpose programming.

- Easy to learn.

- Code can be reused.

- Easy to transfer skills to another language.

Some downsides of Procedural Programming:

- Does not work for complex application.

- The data is exposed to the whole program, hence it is not very safe.

- ait can be hard to modify and debug as the application gets managed.

- Difficult to create new data types.

- Fails to model real world applications, making it difficult to design.

Object Oriented Programming Concept (OOP)

OOP structures a software program into simple, reusable pieces of code blueprints (usually called
classes), which are used to create individual instances of objects. Classes represent broad categories,
like car or dog that share attributes. Classes define what attributes an instance of this type would have,
like color, but not the value of those attributes for a specific object. Classes can also contain functios
called methods available only to objects of that particular type. See the illustration in fig 1 below:

The four principles of object-oriented programming are:

Encapsulation
Abstraction

Inheritance and

Polymorphism

The encapsulation principle states that all important information is contained inside an object and only
select information is exposed.

For abstraction, applying it means that each object should only expose a high level mechanism for using
it. This mechanism should be easy to use and should rarely change over time. It's like a small set of
public methods which any other class can call without knowing how they work.

Inheritance, as a property of OOP forces a more thorough data analysis, reduces development time and
ensures a higher level of accuracy.

Polymorphism gives a way to use a class exactly like its parent so there's no confusion with mixing types,
but each child class keeps its own methods as they are.

Advantages of OOP

- Modularity:

Encapsulation enables objects to be self contained,which makes troubleshooting and collaborative


development easier.

- Flexibility:

Polymorphism enables a single function to adapt to the class it is placed in.

- Security:

Using encapsulation and abstraction, complex code is hidden, software maintenance is easier and
internet protocols are protected.

- Reusability:

Codes can be reused through inheritance.

Some criticisms of OOP

- Can be complicated to write.

- It provides a steep learning curve.

- Require a lot of work to create.

You might also like