Skip to main content

Posts

Showing posts with the label ADT

Transfer google play balance to Paytm, PhonePe, Google Pay or any UPI linked bank account.

To transfer google play balance, opinion rewards or gift cards to PayPal, Paytm, PhonePe, Google Pay or any UPI ID linked bank account , you can use QxCredit :Rewards Convertor app which is available on google play store: You will get back 80% of the google play balance. App link:  https://play.google.com/store/apps/details?id=qxcoding.qx_credit_reboot Follow these steps to transfer your play balance to paypal or UPI: 1) download app from play store. 2) login with your google account and phone number. 3) choose a token amount which you want to convert/transfer. 4) Enter your payout details.(UPI ID or PayPal Email) 5) wait for an acknowledgement mail form qxcredit containing information about your purchased token. 6) you will receive the amount within 3 days. 7) if you face any issues you can raise a query on website: https://qx-credit.web.app/#/contact_support About app: Introducing QxCredit : Rewards Converter Convert /Transfer or Exchange your Google Play Balance and opini...

How to Reverse a Singly linked list ? C/C++ Program

To reverse a given linked list ,we have to point the next (link) of each node to its previous node(ie: the node which is pointing to it.) for that we will maintain three pointers : 1) prev : will point to the node which is pointing to the current node. 2) cur : will point to the node in which we have to change the next(link) to the previous node. 3) next: in the process of changing the cur->next to prev the           cur->next will be lost so to store the address of cur->next we use next pointer. Node definition: typedef struct node{ int val; struct node* next; }* node; as given above the node contains two members value and a pointer pointing to its own datatype which will store the address of another node . reverse_ll(node *first) : function : void reverse_ll(node* first){ node prev=NULL; node cur=(*first); node next=NULL; while(cur){ next=cur->next; cur->next=prev; pr...

How to find the height of binary tree ? program (Python)

The height of binary tree is defined as MAX(depth of leaf nodes)  and depth of a node in turn is defined as (n-1) ,where n = the least number of nodes traversed through, to reach that node. For detailed information on Implementing binary tree in python : refer here. Definition of height function: def height(self): if self.root == None: return 0 else: return self._height(self.root, 0) def _height(self, cur_node, cur_height): if cur_node == None: return cur_height left_height = self._height(cur_node.left_child, cur_height + 1) right_height = self._height(cur_node.right_child, cur_height + 1) return max(left_height, right_height) Here, two functions are used one is used to check that if the binary tree exists or not , if exists then it will call the recursive function to traverse the left branch and right branch depth with respect to the root node , and then returns the bigger of the two by comparing. The value of depth(height ) of...

How to create a Binary Tree Program ( Python / C / C++ )

What is a binary tree? A binary tree is categorized as an abstract data type , whose (I/O) ,(R/W) operations are handled by the user defined functions.A binary tree is a special case of a tree DS where each node except leaf nodes has two children's . for creating a binary tree we will define a class / structure node which will contain the members(left child and right child) and the value. class node: def __init__(self, value=None): self.value = value self.left_child = None self.right_child = None Now , we will write the code for inserting elements in our binary tree, we will create the function in another class containing a member which will store the address of root node and add all successive elements under the root node . def insert(self, value): if self.root == None: self.root = node(value) else: self._insert(value, self.root) def _insert(self, value, cur_node): if value ...

How to find and replace a node in Linked List

For replacing an element in a linked list first we have to find it , for that we will use a function which will do the finding part and give us the node's address (pointer) and then we will replace the value of that node by the value given by the user. Definition of node* find_pos(int) function node* find_pos(int val,int p){ node* cur=first; node* prev=cur; while(cur->val!=val){ prev=cur; cur=cur->next; if(cur==NULL)return NULL; } switch(p){ case 0: return cur; case 1: return cur->next; default:return prev; } } The above function keeps track of the previous node and keep traversing through the linked list until we find the value which is to be replaced, it return the previous node if value of p is -1 or returns current node if p=0 or next one if p=1. Definition of find_replace function void find_replace(int find,int replace){ int c=0; while(node *temp=find_pos(find,0)...

How to Insert ,Delete ( first or last ) nodes in Linked List C / C++

Node definition (Structure) : struct node{ int num; node* next; }; The num variable stores the data given by the user and the pointer (next) stores the address of the next element present in the linked list. Insertion of Nodes : 1) Inserting in beginning :  void insert_beg(int value){ node* n=new node; n->num=value; if(first==NULL){ n->next=NULL; first=n; } else{ n->next=first; first=n; } } the above function ,when called creates a new node and stores the value passed to it in num (variable) ,now the function checks if the list is empty and if it is empty then it is simply marked as the first element in the linked list. if the list is not empty then the pointer (next ) is assgned to the first element address and the marker (first) is given to current element. 2) Insertion at end :  void insert_end(int value){ node* n=new node; n->num=value; n-...

How to Insert ,Delete nodes in between the Linked List

Node definition (Structure) : struct node{ int num; node* next; }; The num variable stores the data given by the user and the pointer (next) stores the address of the next element present in the linked list. Insertion in between nodes (After a given node ) : void insert_inBetween(){ int cvalue,value; cout<<"Enter the value after which you want to insert the new node"<<endl; cin>>cvalue; cout<<"enter the value of new node: "; cin>>value; cout<<endl; node *n,*prev; n->num=value; if(prev=find(cvalue,0)){ n->next = prev->next; prev->next=n; cout<<"node inserted succesfully"; } else{ cout<<"Node value not found"; } } for performing the insertion after an element given by the user , we need to know the location of the node after which it is to be inserted, for this another function (find()) will be called which will return the address of the node af...

Linked List Implementation ( C ++ ) Program

A  Linked list  is a linear collection of data elements, whose order is not given by their physical placement in memory. Instead, each element  points  to the next. It is a  data structure  consisting of a collection of  nodes  which together represent a  sequence .  Linked list is an Abstract Data Type ( ADT ). Node definition ( Structure )  struct node{ int num; node* next; }; The num variable stores the data given by the user and the pointer (next) stores the address of the next element present in the linked list. Operations  void insert_beg(int value); void insert_end(int value); void insert_inBetween(); node* find(int cvalue,int p=0); void input_ll(); void display(); void delete_ll(); void delete_node();   Function definitions 1) Inserting in beginning  void insert_beg(int value){ node* n=new ...

what are Absract Data Types ?

An  abstract data type  ( ADT ) is a  mathematical model  for  data types , where a data type is defined by its behavior ( semantics ) from the point of view of a  user  of the data, specifically in terms of possible values, possible operations on data of this type, and the behavior of these operations. This contrasts with  data structures , which are concrete representations of data, and are the point of view of an implementer, not a user. In simple words ADT can be defined as a user defined data type whose operations for read / write are defined by the programmer in the form of functions. Types of Abstract Data Types : 1) A ssociative array ,   map ,   symbol table , or   dictionary   is an   abstract data type   composed of a   collection   of   (key, value) pairs , such that each possible key appears at most once in the collection. Operations associated with this data type allow: the...