Your ultimate guide in programming...

  • Infix to Postfix Converstion

    * C++ implementation to convert infix expression to postfix*

  • DOUBLY QUEUE IMPLEMENTATION C++

    Double Queue Implemention Guide.

  • Data Structures in JavaScript

    As business logic moves from the back to the front, expertise in front-end engineering becomes even more important. As for front-end engineers, we rely on viable libraries to be effective.

  • Coding Problem To Solve Exercise 1

    here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.

  • Coding Problem To Solve Exercise 2

    here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.

  • Coding Problem To Solve Exercise 3

    * here is Some Coding Problem For Beginners To Boost up their Confidence and to get grip on programming. This problem is for beginner levels for their brainstorming.*

Coding Problem To Solve Exercise 1


Solve Problems To Solve Real-World Problems

 

1)  Write a program to display "Hello World"

 2.)   Add and display three numbers without using a variable.

 3). Write a program, which asks the user to input a number. Then display it. 

4.) Finding the average of three numbers. 

5) Write a program to display the following output using a single cout statement Subject Marks Mathematics 80 

Computer 77

 Physics 70 

6 ) Write a program, which displays the value of “π”, then inputs the radius of a circle from the user and displays its area and circumference. Note: You will have to declare a variable for “π” named as “pi” yourself and initialize it the value 22/7. Area = 𝝅𝒓 𝟐 Circumference = 2πr 

7) Write a program to calculate the area and perimeter of the square.

 8) Write a program to calculate the interest of the bank deposit (formula interest= amount*years*rate/100). 

9) Write a program to input/get a number of float types from the user and then show this number as both floats with decimal points and integer without decimal points. 

10) Write a program, which asks the user to enter two numbers, and then output them after Objectives: • Practice and understanding on basic C++ programs swapping their values using the third variable

OUTPUT-:

Enter the variable "a" = 5

Enter the variable "b" = 6

Before Swapping

Value in the variable "a" = 5

Value in the variable "b" = 6

After Swapping

Value in the variable "a" = 6

Value in the variable "b" = 5


11) Write a program to swap the value of two variables without using a third variable.

Clue: Use arithmetic operators such as division ‘/’ and multiplication * or addition + and subtraction


12) Write a program to Convert Temperature from Fahrenheit (℉) to Celsius (℃) 

(formula C=5/9*(F-32)) 

13) Write a program to calculate the quotient and remainder. Use proper names of variables a. divisor b. dividend c. quotient d. remainder

Share:

Data Structures in JavaScript

 

Data Structures in JavaScript

Introduction

 

        As business logic moves from the back to the front, expertise in front-end engineering becomes even more important. As for front-end engineers, we rely on viable libraries to be effective. Libraries rely on state libraries such as Redux for data management. Together, Reaction and Redux subscribed to the reactive programming paradigm in which UI updates react to data changes. Fast forward, the backend only serves as the API's server, providing only point-of-use to retrieve and update data. In effect, the frontend engineer expects the frontend engineer to handle all controller logic. The growing popularity of microServices and GraphQL confirms this growing trend.                                                                                                                                                   

        In addition to having an aesthetic understanding of HTML and CSS, frontend engineers are also expected to master JavaScript. As the client's data stores become "copies" of the database on the server, the intimate knowledge of the idiomatic data structure becomes important. In fact, an engineer's level of experience can be used to gauge when and why a particular data structure should be used. Now, in a                                                                                                                     

Worried about bad programmer code. Good programmers care about data structures and their relationships.

 

                                - Creator of Lens Torvalds, Linux, and Gut.

 

        At the top level, there are basically three types of data structures. Stacks and rows are array-like structures that differ only in that items are inserted and deleted. Attached lists, trees, and graphs are structures that are attached to nodes that refer to other nodes. Hash tables rely on hash functions to save and search for data.

        In terms of complexity, stacks and rows are the simplest and can be built from LinkedIn. Trees and graphs are the most complex because they enhance the concept of an attached list. Hash tables need to use these data structures to perform satisfactorily. In terms of performance, LinkedIn lists are best suited for recording and storing data, while hash tables perform best for finding and retrieving data.

        To explain why and how this article will be based on the order of dependence. 

 

                                                                    Let's get started!  

Stack

            The most important stack with arguments in JavaScript is the call stack where we always act within the scope of a function. Programmatically, it's just a row with two rows of actions: push and pop. Push adds elements to the top of the array, while pop removes them from the space. In other words, the stacks follow the "List In, First Out" protocol (LIFO).


Queue 

        JavaScript is a program-driven programming language that makes it possible to support blocking operations. Internally, the browser manages only one thread to run the entire JavaScript code, uses the event queue to bring listeners to the queue and the event loop to listen to the registered events. To support Christianity in a single-thread environment (to save CPU resources and enhance the web experience), listeners deserve action and only execute when the call stack is empty.                                                                                            

        Promises depend on this event-driven architecture to allow a “synchronous-style” execution of asynchronous code that does not block other operations.

Programmatically, rows are just rows with two basic functions: non-shift and pop. In shift moves the signal to the end of the array, while pop makes them deserving from the beginning of the array. In other words, the queue follows the "first in, first out" protocol (FIFO). If the direction is reversed, we can change the inset and pop with push and shift, respectively.

 

PLEASE COMMENT TO ABOUT THE BLOG AND SHARE YOUR CODING EXPERIENCES WITH US AT asadsiddique.a@gmail.com



Share:

Want to learn web development but don’t know where to start?

 



تو ، کیا آپ ویب ڈویلپمنٹ سیکھنے اور ویب ڈویلپر بننے میں دلچسپی                                         رکھتے ہیں؟

 سب سے پہلے ، مبارکباد۔ آپ نے ایک بہت اچھا انتخاب کیا 





اور چونکہ آپ یہ پڑھ رہے ہیں ، آپ پہلے ہی کسی فیس بک گروپ ، سبریڈیٹ یا دیگر آن لائن کوڈنگ کمیونٹی کے ایک سرگرم رکن ہوسکتے ہیں۔ جو شروع کرنے کے لئے اور آپ کے منتخب کردہ تعاقب میں مدد حاصل کرنے کے لئے ایک بہترین جگہ ہے۔

ایک بار پھر ، آپ ابھی تک بہت اچھا کر رہے ہیں۔

لہذا آپ کے پس منظر پر انحصار کرتے ہوئے ، آپ سوچ رہے ہوں گے کہ ویب ڈویلپمنٹ کو کہاں سے سیکھنا شروع کریں۔ اگر آپ بنیادی طور پر ادھر ادھر ادھر ادھر ادھر گھوم رہے ہیں تو ، آپ کو وہاں کی تمام زبانوں ، فریم ورکوں اور سیکھنے کے وسائل سے تھوڑا سا مغلوب ہوسکتا ہے۔

ٹھیک ہے ، فکر نہ کرو۔ تم اکیلے نہیں ہو. گوگل آپ کا سب سے اچھا دوست یا آپ کا بدترین دشمن ہوسکتا ہے۔ یہ صرف اس پر منحصر ہے کہ آپ اسے کس طرح استعمال کرتے ہیں۔


                                                    اختتام کو دھیان میں رکھیں۔

ویب ڈویلپمنٹ کو سیکھنے کے وقت شروع کرنے کے دوران میں سب سے پہلے جن چیزوں کی تجویز کرتا ہوں ان میں سے ایک یہ ہے کہ کسی واضح مقصد کا فیصلہ کریں ، اور اسے ذہن میں رکھیں۔

ہوسکتا ہے کہ آپ کیریئر میں تبدیلی لانا چاہتے ہو۔ ہوسکتا ہے کہ آپ کو کسی ایپ کے لئے غلط خیال ہو۔ یا ہوسکتا ہے کہ آپ صرف تفریح​​کے سیکھنا چاہتے ہو۔

آپ کا مقصد جو بھی ہو ، یہ سمجھنا ضروری ہے کہ آپ یہ کیوں کر رہے ہیں۔ یہ تفہیم آپ کو سیکھنے کے وقت کے ساتھ زیادہ کارآمد ہونے میں مدد دے گی۔ جب آپ ہار ماننے کو محسوس کریں گے تو ان اوقات میں آپ کی حوصلہ افزائی کرنے میں بھی مدد ملے گی۔

یاد رکھنا ، قطع نظر اس بات سے قطع نظر کہ اب حتمی مقصد کتنا وسیع اور دور دکھائی دے سکتا ہے ، آپ اسے سخت محنت اور استقامت کے ساتھ حاصل کرسکتے ہیں۔

فرض کریں کہ آپ کے پاس کوئی پچھلا تجربہ نہیں ہے ، شروعات میں یہ فیصلہ کرنا ایک اچھا خیال ہے کہ کیا آپ کی دلچسپی بیک سینڈ یا فرنٹ اینڈ ڈویلپمنٹ میں ہے۔ میں فرق کو مختصر طور پر بیان کرتا ہوں۔


                                                       فرنٹ اینڈ

آخر صارف یہی دیکھتا ہے اور اس صفحے پر بات چیت کرتا ہے۔ اس کے سارے ڈیزائن ، فینسی اثرات ، ترتیب اور منظر کشی جو صارف کا تجربہ تخلیق کرتی ہے۔

عام طور پر فرنٹ اینڈ ڈویلپرز بہترین ڈیزائن کی مہارت اور قابل رسائ اور صارف کے تجربے کے جذبے کے ساتھ بصری تخلیقات ہوں گے۔ اکثر فرنٹ اینڈ ویب ڈویلپمنٹ کے ساتھ وابستہ ٹیکنالوجیز HTML ، CSS ، jQuery اور جاوا اسکرپٹ ہیں۔

                                    

                                                                Backend


یہ وہ حصہ ہے جو عام طور پر ڈیٹا کو پروسس ، اسٹور اور جوڑتوڑ کرتا ہے۔ ویب سائٹ یا درخواست کام کرنے کا طریقہ یہ ہے۔ بیک اینڈ ڈویلپر عام طور پر اچھ مسئلے حل کرنے والے ، منطقی مفکرین ہوتے ہیں جو کسی ویب سائٹ یا ایپلی کیشن کی فعالیت میں دلچسپی رکھتے ہیں۔ بیک اینڈ ڈویلپمنٹ عام طور پر پی ایچ پی ، ازگر اور روبی جیسی سرور کی زبانوں سے وابستہ ہوتا ہے۔

میں بالکل دور سے ہی جانتا تھا کہ میرے پاس ابھی بصری ڈیزائن کے لئے ایسا شعلہ نہیں تھا جو بہت سارے ڈویلپرز کو فرنٹ اینڈ ڈویلپمنٹ کی طرف راغب کرتا ہے۔ انجینئرنگ اور تعمیرات میں میرے پس منظر کی وجہ سے مجھے شاید یہ فیصلہ سب سے زیادہ آسان معلوم ہوا۔ میں مسئلہ کو حل کرنے میں قدرتی طور پر زیادہ مشابہ ہوں ، اور یہ معلوم کرنے کی کہ چیزیں کس طرح کام کرتی ہیں ، چیزوں کو خوبصورت لگانے سے!

کسی بھی طرح سے ، جہاں بھی آپ کی دلچسپی مضمر ہے ، میں اب بھی سوچتا ہوں کہ شروع کرنے کا بہترین مقام کچھ بنیادی HTML اور CSS کو سیکھنا ہے۔ بہرحال ، اس سے کوئی فرق نہیں پڑتا ہے کہ ترقی کے کس شعبے میں آپ آخر کار کام کرنا چاہتے ہیں ، آپ کو ابھی بھی کسی بھی طرح کی ہلکی سی شکل میں ویب پیج پر ظاہر کرنے کے اہل ہونے کی ضرورت ہے۔

سب سے پہلے سب سے پہلے ، براہ راست فری کوڈکیمپ یا کوڈکیڈیمی کی طرف بڑھیں اور ان کے "HTML اور CSS" کورس لیں۔ اس سے آپ کو یہ احساس دلانا چاہئے کہ ان ٹیکنالوجیز کے بارے میں کیا ہے۔

نیز ، ان کے انٹرایکٹو سیکھنے کے ماحول کی وجہ سے ، وہ آپ کو مقامی ترقیاتی ماحول کو پہلے ترتیب دینے کا طریقہ معلوم کرنے کی بجائے ، آپ کو سیدھے کوڈ لکھنا شروع کردیں گے۔ کچھ کوڈ لکھنے اور کچھ ٹیسٹ فورا. پاس کرنے کے علاوہ آپ کے اعتماد کو مزید تقویت نہیں ملے گی۔


Share:

DOUBLY QUEUE IMPLEMENTATION C++

DOUBLY QUEUE IMPLEMENTATION C++


// DOUBLY QUEUE IMPLEMENTATION
#include<iostream>
using namespace std;
struct Node{ //NODE STRUCTURE
Node *prev;
int data;
Node *next;
};
class Doubly_Queue{ //DOUBLY_QUEUE CLASS
Node *front;
Node *rear;
public:
Doubly_Queue()
{
front = NULL;
rear = NULL;
}
void insertion(int x) //INSERTION FUNCTION
{
Node *ptr = new Node;
ptr->data = x;
if(rear == NULL)
{
ptr->prev = NULL;
ptr->next = NULL;
rear = ptr;
front = ptr;
}
else
{
rear->next = ptr;
ptr->prev = rear;
ptr->next = NULL;
rear = ptr;
}

}
int remove() // REMOVE OR DELETE FUNCTION
{
int copy = front->data;
Node *rptr = front;
front = front->next;
if(front == NULL)
{
rear = NULL;
}
delete rptr;
return copy;
}
void previous() // PERVIOUS VALUES DISPLAYING FUNCTION
{
Node *curr = rear;
while(curr != NULL)
{
cout<<curr->data<<" ";
curr = curr->prev;
}
}
void display() // NORMAL DISPLAY FUNCTOIN
{
Node *curr = front;
while(curr != NULL)
{
cout<<curr->data<<" ";
curr = curr->next;
}
}
};
// MAIN DRIVEN...
int main()
{
Doubly_Queue q; // OBJECT OF CLASS
char choice;
do{
int input;
cout<<"1) TO INSERT: \n";
cout<<"2) TO REMOVE: \n";
cout<<"3) FOR PREVIOUS DISPLAY: \n";
cout<<"4) FOR NORMAL DISPLAYING: ";
cin>>input;
system("clear");
switch (input)
{
case 1:
int num;
cout<<"ENTER NUMBER TO INSERT :";
cin>>num;
q.insertion(num);
break;
case 2:{
cout<<"REMOVED NUMBER IS: "<<q.remove()<<endl;
break;
}
case 3:{
q.previous();
break;
}
case 4:{
q.display();
break;
}
default:
cout<<"ERROR 404: ";
break;
}
cout<<"DO YOU WANT TO MORE: (Y/N)...";
cin>>choice;
system("clear");
}while(choice == 'y');
return 0;

}

Share:

Queue Using Linked List c++


#include<iostream>
using namespace std;
struct Node{
int data;
Node *next;
};
class Queue_Linklist{
Node *front;
Node *rear;
public:
Queue_Linklist(){
rear = front = NULL;
}
void insert(int num){
Node *temp = new Node;
temp->data = num;
temp->next = NULL;
if(rear == NULL){
rear = temp;
front = temp;
}
else{
rear->next = temp;
rear = temp;
}
}
int remove(){
int copy = front->data;     
Node *del = front;
front = front->next;
if(front == NULL){
rear = NULL;
}
delete del;
return copy;
}
void Display()
{
Node *temp = front;
cout<<"DATA IN QUEUE IS: ";
while(temp != NULL){
cout<<temp->data<<" ";
temp = temp->next;
}
}
};
int main()
{
Queue_Linklist Q;
char choice;
do{
int input;
cout<<"1) TO INSERT NUMBER: \n";
cout<<"2) TO REMOVE NUMBER: \n";
cout<<"33) TO DISPLAY QUEUE: ";
cin>>input;
system("cls");
switch(input){
case 1:{
int num;
cout<<"ENTER NUMBER: ";
cin>>num;
Q.insert(num);
break;
}
case 2:{
cout<<"REMOVED NUMBER IS: "<<Q.remove()<<endl;
break;
}
case 3:{
Q.Display();
break;
}
default:{
cout<<"EROR 404: "<<endl;
break;
}
}
cout<<"\nDO YOU WANT TO CONT...(Y/N)...";
cin>>choice;
system("cls");
}while(choice == 'y');
return 0;
}

Share:

Queue implementation in C++


                    //Queue implementation in C++
#include<iostream>           
using namespace std;
class Queue {
int item[5];
int front;
int rear;
public:
Queue() { //Constructor....
front = 0;
rear = -1;
}
void insert(int x) { // INSERTION FUNCTION TO INSERT VALUES IN QUEUE....
item[++rear] = x;
}
bool isempty() {
if (front>rear)
return true;
return false;
}
void apinsert(int x) { // ORDERING OF DATA IN QUEUE IN ASSENDING ORDER....
if (isempty()) {
insert(x);
}
else if (x >= item[rear])
{
insert(x);
}
else
{
Queue q2;
while (!isempty()) {
int t = remove();
if (x<t) {
q2.insert(x);
q2.insert(t);
break;
}
else
{
q2.insert(t);
}
}
while (!isempty())
q2.insert(remove());

front = 0;
rear = -1;
while (!q2.isempty()) {
insert(q2.remove());
}

}
}

int remove()
{
return item[front++];
}
void dislpay()
{

for (int k = 4; k>rear; k--)
cout << "\nEmpty";
for (int i = rear; i >= front; i--)
cout << endl << item[i];

for (int j = (front - 1); j >= 0; j--)
cout << "\nEmpty";
}
bool isfull()
{
if (rear >= 4)
return true;
return false;
}
};
int main() // MAIN DRIVER....
{
Queue q1;

char repeat = 'y';
do {

int input;
cout << "1) Press '1' to insert: " << endl;
cout << "2) Press '2' to remove: " << endl;
cout << "3) Press '3' to Display: " << endl;
cin >> input;
system("cls");          //STANDARD LIBARAY HEADER FILE   (TO CLEAR SCREEN)
switch (input) {
case 1: {
int num;
cout << "Enter Number: ";
cin >> num;
system("cls");
q1.apinsert(num);
break;
}
case 2: {
if (q1.isempty())cout << "\nThe queue is already empty";
else
cout << "\nThe removed value is:" << q1.remove();
break;
}
case 3: {
q1.dislpay();
break;
}
default:
cout << "Error 404: ";
}
cout << "\nRepeat: y/n..";
cin >> repeat;
system("cls");
} while (repeat == 'y');
return 0;
}

Share:

Linked List vs Array

Linked List vs Array

 

Key Differences Between Array and Linked List

1. An array is the data structure that contains a collection of similar type data elements whereas the Linked list is considered as non-primitive data structure contains a collection of unordered linked elements known as nodes.
2. In the array the elements belong to indexes, i.e., if you want to get into the fourth element you have to write the variable name with its index or location within the square bracket.
3. In a linked list though, you have to start from the head and work your way through until you get to the fourth element.
4. Accessing an element in an array is fast, while Linked list takes linear time, so it is quite a bit slower.
5. Operations like insertion and deletion in arrays consume a lot of time. On the other hand, the performance of these operations in Linked lists is fast.
6. Arrays are of fixed size. In contrast, Linked lists are dynamic and flexible and can expand and contract its size.
7. In an array, memory is assigned during compile time while in a Linked list it is allocated during execution or runtime.
9. Elements are stored consecutively in arrays whereas it is stored randomly in Linked lists.
10. The requirement of memory is less due to actual data being stored within the index in the array. As against, there is a need for more memory in Linked Lists due to storage of additional next and previous referencing elements.
11. In addition memory utilization is inefficient in the array. Conversely, memory utilization is efficient in the linked list.
 
Following are the points in favor of Linked Lists:
(1) The size of the arrays is fixed: So we must know the upper limit on the number of elements in advance. Also, generally, the allocated memory is equal to the upper limit irrespective of the usage, and in practical uses, the upper limit is rarely reached.
(2) Inserting a new element in an array of elements is expensive because a room has to be created for the new elements and to create room existing elements have to be shifted.
 
For example, suppose we maintain a sorted list of IDs in an array id[].
id[] = [1000, 1010, 1050, 2000, 2040, …..].
And if we want to insert a new ID 1005, then to maintain the sorted order, we have to move all the elements after 1000 (excluding 1000).
Deletion is also expensive with arrays until unless some special techniques are used. For example, to delete 1010 in id[], everything after 1010 has to be moved.
 
So Linked list provides the following two advantages over arrays
1) Dynamic size
2) Ease of insertion/deletion
 
Linked lists have following drawbacks:
1) Random access is not allowed. We have to access elements sequentially starting from the first node. So we cannot do a binary search with linked lists.
2) Extra memory space for a pointer is required with each element of the list.
3) Arrays have better cache locality that can make a pretty big difference in performance.
Share:

Newest Post

Coding Problem To Solve Exercise 3

                   Coding Problem To Solve Exercise 3 Objectives: Practice and understanding of basic c++ programs Control Structure(repetit...

Popular Posts

Recent Posts