#### Logic Basics Structure (logic series -2)

In last Section we have seen you must need your basic logic strong to be a well-equipped developer who will be ready for the future. Let’s see the Basic Application logic Subjects that we are going to see.

- Basic Data Structures: Arrays, Strings, Stacks, Queues

- Asymptotic analysis (Big-O notation)

- Basic math operations (addition, subtraction, multiplication, division, exponentiation)

- Sqrt(n) primality testing

- Euclid’s GCD Algorithm

- Basic Recursion

- Greedy Algorithms

- Basic Dynamic Programming

- Naive string searching

- O (n logn) Sorting

- Binary Searching

These are the basics that we must know, we will see them one by one we will start with Basic Data structures

Any programming Language is depend upon some ground factors like Storage , speed and reliability (actually there are a lot but If we can go with these) , then there is also one of the factor like how it debug or compile the piece of code that includes how the interpreter or the compiler works .

Variable – What are Variables?

In Normal way we can say that variable is a single room which can store only one person similarly in programming language Variable is place where it can store the Value, as we have address for any place similarly, we have address for all the variables so compiler can identify the value from its address and can use them. Then there comes the datatype according to that we can define like what kind what kind of value we can store in that variable as it can be a number or it can be a word or a single character

Datatype’s –

Integer – It can only store complete number values e.g. int a=54, it cannot store a fraction values as if we assign something like int a=54.36, it will not store 54.36 it will only store 54 into the memory location.

Char (Character) – It can only store one Character value into the memory e.g. char a=’a’

If we try to store a=’a’,‘b’; it will give us an error for this as it does not contain enough space  for this as it will consider them as a different values, but if we try to store a=’ab’; it will successfully store the value as it will consider it as a single value only.

Float - It can store the fraction values into its memory location. E.g. float a=52.369; it can also store the whole number but it will be also in fractional format as if we try to store float a=52; it will store a=52.00 into its memory location. Though it also have some limit to store the value, it can not store the value which is bigger than 3.402823466 E + 38 (now that is quite a large number, but still) for that we have double

Double - if we want to store a large number which float is incapable to store then we can use double for this.

Boolean – this helps us to store Boolean values, which are like 0 or 1, yes or no, true or false significantly.

Then there is also some custom variable like string- which is also consider as a character array

Array – What is an Array?

Arrays is the place where we can store more than one value (in some places that need to be of similar datatype or in some places we can store of any datatype).

As we have considered the variable as a room on similar ground, we can say that array is a building where we can store multiple values in one place, we just have to go to the address of that building and that’s it we can access the values of the building. We have to refer the datatype of the array so we can assign the type of value to that array.

e.g. int ArrayN; - it is the basic declaration structure of an array int refers to datatype ArrayN refers to name of the array and [ ] – this bracket indicates that we are referring about an array, value 50 refers to the amount of array that we can store into that array , though it is not necessary that we must refer to the array value but we can do that at least in our starting programs.

Array will always start from 0 and ends at the value that we have assign.

ArrayN

ArrayN

ArrayN

.

.

.

.

.

ArrayN

It will follow this structure the array starting from 0 to 50.

A single array structure will look like this.

ArrayN -

ArrayN value

There are lots of concepts that will depend on Array, we will defiantly look at them at a time.

Stack - Stack and Queue

Both are important factors of data structure and ultimately programming We will Look at them one by one.

What is Stack?

Stack is one another concept that it is similar in structure. As it is similar like array in structure. It stores a more that one values (as the limit that we have given to it) under one variable. But it stores the values of the variable in slightly different manner it considers the storage as a trunk it has only one opening so whatever goes first it will come back last as it works on the Rule of first in last out.

E.g. ArrayN – It will look something like this.

ArrayN

ArrayN

ArrayN

PUSH and POP these are two function that works with Stack.

PUSH will push or insert the element into a Stack Array.

POP will get out the element out of a Stack Array.

What is Queue?

Queue is contemporary to the stack both follow the Array structure but have different structure of storage. Queue is just like its name follow the similar structure. It follows the structure of first in first out.

E.g. ArrayN;

ArrayN

ArrayN

ArrayN

ArrayN

If ArrayN will come to an array first it will comes out first also .just like the queue that most of us follow at anywhere if you comes first you will come out of it first.

We have seen is our basic syllabus and basic algorithmic concepts.  We will  discuss some more topics in next series.