text:
//size of the link list can be arranged
//insertion and deletion in linked list is much easier then array
//take more merory
//non continous memory location
//link list is created in heap

//implement link list and delete an element into the list

#include<iostream>
using namespace std;

    //SELF REFFERENTIAL DATA STRUCTURE
    //which includes at least one member that is a pointer
    //to the same structure

    struct node{
    //structure can store many different data types
        int data;
        node*next; //self refrencing structure
    };

    node*head = NULL; //initial linked list is empty

    void insert_at_beginning(int new_data)
    {
        node* ptr=new node;//dynamically alloted new node
        ptr->data = new_data;
        ptr->next = head;
        head = ptr;
    };

    void insert_at_end(int new_data)
    {
        node* ptr=new node;//create a new node by dynamically allocation
        ptr->data = new_data;
        ptr->next = NULL ;
        //if head is NULL, i.e linked list is empty
        if(head==NULL)
            {
                head = ptr;
            }
        else
        {
            node *temp = head;
            while(temp->next != NULL)
            {
                temp = temp->next;
            }
            temp->next = ptr ;
        }

    };

    void insert_at_given_index(int new_data , int position)
    {
        node *ptr = new node;
        ptr->data = new_data;
        ptr->next = NULL;
        if(head == NULL)
        {
            head = ptr;
        }
        else
        {
            node *temp = head ;
            for(int i=0 ; i<position-1;i++)
            {
                temp = temp->next;
            }
            ptr->next=temp->next;
            temp->next = ptr;
        }

    };

    void display()
    {
        node*ptr;
        ptr=head;
        while(ptr != NULL)
        {
            cout<<ptr->data<<" ";
            ptr = ptr->next;
        }
    };

    void deletion()
    {
        node *temp = head;
        int dlt;
        cout<<"Enter the index you want to delete :";
        cin>>dlt;
        for (int i = 0; i < dlt-1; i++)
        {
            temp=temp->next;
        }
        node *temp2 = head;
        for(int i = 0; i<dlt;i++)
        {
            temp2 = temp2->next;
        }
        temp->next = temp2->next ;

    }

    int main()
    {
        int n;
        cout<<"Enter the number of elements of the linked list : ";
        cin>>n;
        int element;
        for(int i=0;i<n;i++)
        {
            cout<<"Enter the"<<" "<<i+1<<" "<<"element of the link list : ";
            cin>>element;
            insert_at_end(element);
        }
        cout<<"Our link list is : "<<endl;
        display();
        cout<<endl;

        //insertion in the beginning
        int operation1;
        cout<<"If you want to insert elements in the beginning, then enter 1 otherwise 0. ";
        cin>>operation1;
        if(operation1==1)
        {
            int inserting;
            cout<<"Enter the element you want to insert :"<<endl;
            cin>>inserting;
            insert_at_beginning(inserting);
        }
        cout<<"Resultant link list is :"<<endl;
        display();

        //insertion at end
        cout<<endl;
        int operation2;
        cout<<"If you want to insert elements in the end, then enter 1 otherwise 0. ";
        cin>>operation2;
        if(operation2==1)
        {
            int inserting;
            cout<<"Enter the element you want to insert :"<<endl;
            cin>>inserting;
            insert_at_end(inserting);
        }
        cout<<"Resultant link list is :"<<endl;
        display();

        //insertion at a specific place
        cout<<endl;
        int operation3;
        cout<<"If you want to insert elements somewhere between the linked list, then enter 1 otherwise 0. ";
        cin>>operation3;
        if(operation3==1)
        {
            int inserting;
            cout<<"Enter the element you want to insert :"<<endl;
            cin>>inserting;
            int position;
            cout<<"Enter the index of the new element : ";
            cin>>position;
            insert_at_given_index(inserting , position);
            cout<<endl;1
        }
        display();

        int operation4;
        cout<<"Enter 1 if you want to delete any element :";
        cin>>operation4;
        if(operation4 = 1)
        {
            deletion();
        }
        cout<<"Resultant link list is :"<<endl;
        display();

        return 0;
    }


text:
class Solution {
public:
    // reverse a linked list code
    ListNode* reverseList(ListNode* head) {

        ListNode* prev=NULL;
        ListNode* cur=head;
        ListNode* n;

        while(cur!=NULL){

            n=cur->next;
            cur->next=prev;
            prev=cur;
            cur=n;

        }

        return prev;
    }

    // actual function which gets called to check if a list is palindrome or not
    bool isPalindrome(ListNode* head) {

        // find middle of the linked list
        ListNode* fast = head;
        ListNode* slow = head;
        while(fast != NULL && fast->next != NULL){
            fast = fast->next->next;
            slow = slow->next;
        }

        // reverse the latter half of the list
        ListNode* revHead = reverseList(slow);

        // traverse in each half to check is it palindrome or not
        ListNode* firstHalf = head;
        ListNode* secondHalf = revHead;

        while(secondHalf != NULL){
            if(firstHalf->val != secondHalf->val){
                return false; // not palindrome;
            }
            firstHalf = firstHalf->next;
            secondHalf = secondHalf->next;
        }

        return true; // palindrome
    }
};

file_name: Merge Sorted Array.cpp

mime_type: text/x-c++


text:
// C++ program to create a Complete Binary tree from its Linked List
#include <iostream>
#include <string>
#include <queue>
using namespace std;

// Linked list node
struct ListNode
{
	int data;
	ListNode* next;
};

struct BinaryTreeNode
{
	int data;
	BinaryTreeNode *left, *right;
};

void push(struct ListNode** head_ref, int new_data)
{
	// allocate node and assign data
	struct ListNode* new_node = new ListNode;
	new_node->data = new_data;
	new_node->next = (*head_ref);
	(*head_ref) = new_node;
}

BinaryTreeNode* newBinaryTreeNode(int data)
{
	BinaryTreeNode *temp = new BinaryTreeNode;
	temp->data = data;
	temp->left = temp->right = NULL;
	return temp;
}

void convertList2Binary(ListNode *head, BinaryTreeNode* &root)
{
	queue<BinaryTreeNode *> q;

	// Base Case
	if (head == NULL)
	{
		root = NULL;
		return;
	}

	root = newBinaryTreeNode(head->data);
	q.push(root);
	head = head->next;
	while (head)
	{
		BinaryTreeNode* parent = q.front();
		q.pop();
		BinaryTreeNode *leftChild = NULL, *rightChild = NULL;
		leftChild = newBinaryTreeNode(head->data);
		q.push(leftChild);
		head = head->next;
		if (head)
		{
			rightChild = newBinaryTreeNode(head->data);
			q.push(rightChild);
			head = head->next;
		}

		parent->left = leftChild;
		parent->right = rightChild;

	}
}

// Utility function to traverse the binary tree after conversion
void inorderTraversal(BinaryTreeNode* root)
{
	if (root)
	{
		inorderTraversal( root->left );
		cout << root->data << " ";
		inorderTraversal( root->right );
	}
}

int main()
{
	// create a linked list shown in above diagram
	struct ListNode* head = NULL;
	push(&head, 36);
	push(&head, 30);
	push(&head, 25);
	push(&head, 15);
	push(&head, 12);
	push(&head, 10);

	BinaryTreeNode *root;
	convertList2Binary(head, root);

	cout << "Inorder Traversal of the constructed Binary Tree is: \n";
	inorderTraversal(root);
	return 0;
}


text:
#include<bits/stdc++.h>
 using namespace std;

 struct Listnode{
   int val;
   ListNode *next;
   ListNode(int c){
     val=c;
     next=NULL;
   }
 }
 ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
         /*
             # Imagine the lists as follows:
                     |---------
                               \
                                 --------
                               /
                -----|---------

             # Now, we can clearly see that the point of intersection is equidistant from the node at | for both lists
             # How to find this node |?

             # Traverse both lists at a one-node-at-a-time pace. Let S be the pointer to the shorter LL, and L be the pointer to the longer LL
                     |---------
                               \
                                 --L----S
                               /
                -----|---------

                L will be exactly 5 steps(in this case) behind S, because that is the length difference bw these two LL

                Move both pointers forward by one. S becomes null.

                Now restart the pointer S at the beginning of the longer LL

                     |---------
                               \
                                 ---L----
                               /
                S----|---------

                When L reaches the end, S will have crossed the extra distance at the beginning. Restarting L at the shorter LL leads to:
                     L--------
                               \
                                 --------
                               /
                -----S---------

                Et voila! We can easily find the point of intersection now!

                 Note that - for linked lists with no intersection, the point of intersection will simply by the end of both LL:
                     |--------
                               \
                                 NULL
                               /
                -----|---------
         */

         if(!headA){
             return headB;
         }
         if(!headB){
             return headA;
         }

         ListNode *A=headA,*B=headB;
         while(A && B && A!=B){
             A=A->next;
             B=B->next;

             if(A==B){
                 return A;
             }

             if(!A){
                 A=headB;
             }
             if(!B){
                 B=headA;
             }
         }

         return A;
     }

 int main(){
   //call getIntersectionNode()
 }


text:
#include <stdio.h>
#include <stdlib.h>
struct poly
{
    int coef, pow;
    struct poly *nxt;
};
typedef struct poly poly;

int is_empty(poly *p)
{
    return p == NULL;
}

void append(int coef, int pow, poly **p)
{
    poly *n = (poly *)malloc(sizeof(poly));
    n->coef = coef;
    n->pow = pow;
    n->nxt = NULL;
    if (is_empty(*p))
        *p = n;
    else
    {
        poly *temp = *p;
        while (temp->nxt != NULL)
            temp = temp->nxt;
        temp->nxt = n;
    }
} // insertion at the end

void display(poly *p)
{
    if (p == NULL)
    {
        printf("\nEmpty Polynomial\n");
        return;
    }
    printf("%d", p->coef);
    if (p->pow != 0)
    {
        printf("x");
        if (p->pow != 1)
            printf("^%d", p->pow);
    }
    poly *temp = p->nxt;
    while (temp != NULL)
    {
        if (temp->coef > 0)
            printf("+");
        printf("%d", temp->coef);
        if (temp->pow != 0)
        {
            printf("x");
            if (temp->pow != 1)
                printf("^%d", temp->pow);
        }
        temp = temp->nxt;
    }
}

int main()
{
    int deg, coef, i;
    poly *p = NULL;
    printf("\nEnter the degree of the polynomial : ");
    scanf("%d", &deg);
    for (i = deg; i >= 0; i--)
    {
        printf("\nEnter the coefficient for power %d: ", i);
        scanf("%d", &coef);
        if (coef != 0)
            append(coef, i, &p);
    }
    printf("\nThe polynomial is : ");
    display(p);
    printf("\n\n");
    return 0;
}


text:
# Python Program to find the area of triangle

a = 5
b = 6
c = 7

# Uncomment below to take inputs from the user
# a = float(input('Enter first side: '))
# b = float(input('Enter second side: '))
# c = float(input('Enter third side: '))

# calculate the semi-perimeter
s = (a + b + c) / 2

# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)


text:
print("Rock ,Paper,Scissor...")
win=0
player1=0
player2=0
trails=int(input("No.of Trails\n"))
while(win<trails):
   choose1=str(input("Player 1 choose any R or S or P in capital\n"))
   choose2=str(input("Player 2 choose any R or S or P in capital\n"))
   if(choose1==choose2):
    print("Same")
   elif((choose1=="R" and choose2=="S") or (choose1=="P" and choose2=="R") or (choose1=="S" and choose2=="P")):
    player1=player1+1
   elif((choose2=="R" and choose1=="S") or (choose2=="P" and choose1=="R") or (choose2=="S" and choose1=="P")):
    player2=player2+1
   win=win+1
if(player1>player2):
    print("Player 1 is the Winner")
elif(player2>player1):
    print("Player 2 is the Winner")
else:
    print("Tie")


text:
import requests
import random
import json

q_obj = random.choice(json.loads(requests.get("https://zenquotes.io/api/quotes/").text))
print(f"{q_obj['q']} - {q_obj['a']}")


text:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

search = input('Enter the name of reciever: ')
message = input('Enter the message: ')
photo = input('Enter the path of video/photo: ')
count = int(input('Enter the number of times the mesage should be sent: '))

class WhatsppBot:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://web.whatsapp.com/')
        sleep(15)
        self.driver.find_element_by_xpath("//*[@id='side']/div[1]/div/label/div/div[2]").send_keys(search,Keys.RETURN)

    def message(self):
        messagebox = self.driver.find_element_by_xpath("//*[@id='main']/footer/div[1]/div[2]/div/div[2]")
        for n in range(count):
            messagebox.send_keys(message, Keys.RETURN)

    def media(self):

        for n in range(count):
            self.driver.find_element_by_xpath("/html/body/div[1]/div/div/div[4]/div/header/div[3]/div/div[2]/div").click()
            photo_input = self.driver.find_element_by_xpath("//*[@id='main']/header/div[3]/div/div[2]/span/div/div/ul/li[1]/button/input").send_keys(photo)
            sleep(2)
            photo_send = self.driver.find_element_by_xpath("//span[@data-icon='send-light']").click()

    print(Exception)

bot=WhatsppBot()
bot.message()
bot.media()


text:
def compAndSwap(a, i, j, dire):
    if (dire == 1 and a[i] > a[j]) or (dire == 0 and a[i] > a[j]):
        a[i], a[j] = a[j], a[i]

def bitonicMerge(a, low, cnt, dire):
    if cnt > 1:
        k = cnt//2
        for i in range(low, low+k):
            compAndSwap(a, i, i+k, dire)
        bitonicMerge(a, low, k, dire)
        bitonicMerge(a, low+k, k, dire)

def bitonicSort(a, low, cnt, dire):
    if cnt > 1:
        k = cnt//2
        bitonicSort(a, low, k, 1)
        bitonicSort(a, low+k, k, 0)
        bitonicMerge(a, low, cnt, dire)

def sort(a, N, up):
    bitonicSort(a, 0, N, up)

a = [3, 7, 4, 8, 6, 2, 1, 5]
n = len(a)
up = 1

sort(a, n, up)
print("Sorted array is")
for i in range(n):
    print("%d" % a[i], end=" ")


text:
# Python program to print DFS traversal for complete graph
from collections import defaultdict

# This class represents a directed graph using adjacency
# list representation
class Graph:

	# Constructor
	def __init__(self):

		# default dictionary to store graph
		self.graph = defaultdict(list)

	# function to add an edge to graph
	def addEdge(self,u,v):
		self.graph[u].append(v)

	# A function used by DFS
	def DFSUtil(self, v, visited):

		# Mark the current node as visited and print it
		visited[v]= True
		print v,

		# Recur for all the vertices adjacent to
		# this vertex
		for i in self.graph[v]:
			if visited[i] == False:
				self.DFSUtil(i, visited)

	# The function to do DFS traversal. It uses
	# recursive DFSUtil()
	def DFS(self):
		V = len(self.graph) #total vertices

		# Mark all the vertices as not visited
		visited =[False]*(V)

		# Call the recursive helper function to print
		# DFS traversal starting from all vertices one
		# by one
		for i in range(V):
			if visited[i] == False:
				self.DFSUtil(i, visited)

# Driver code
# Create a graph given in the above diagram
g = Graph()
g.addEdge(0, 1)
g.addEdge(0, 2)
g.addEdge(1, 2)
g.addEdge(2, 0)
g.addEdge(2, 3)
g.addEdge(3, 3)

print "Following is Depth First Traversal"
g.DFS()


text:
import os
import time
import random

os.system('color 0a')

nums = [1,0]
tm = 0

while tm < 30:
    print(random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),random.randrange(1,5)* " ",
    random.choice(nums),)

    tm = tm + 0.1

    time.sleep(0.1)


text:
import pygame
import sys
from math import *

# Initialization of Pygame Window:
pygame.init()

width = 500
height = 500

display = pygame.display.set_mode((width, height))
clock = pygame.time.Clock()
pygame.display.set_caption("Fidget Spinner Simulation")

# Colors
background = (51, 51, 51)
white = (240, 240, 240)
red = (176, 58, 46)
dark_red = (120, 40, 31)
dark_gray = (23, 32, 42)
blue = (40, 116, 166)
dark_blue = (26, 82, 118)
yellow = (183, 149, 11)
dark_yellow = (125, 102, 8)
green = (29, 131, 72)
dark_green = (20, 90, 50)
orange = (230, 126, 34)
dark_orange = (126, 81, 9)

# Close the Pygame Window
def close():
    pygame.quit()
    sys.exit()

# Drawing of Fidget Spinner on Pygame Window
def show_spinner(angle, color, dark_color):
    d = 80
    innerd = 50
    x = width/2 - d/2
    y = height/2
    l = 200
    r = l/(3**0.5)
    w = 10
    lw = 60

    # A little math for calculation the coordinates after rotation by some 'angle'
    # x = originx + r*cos(angle)
    # y = originy + r*sin(angle)

    centre = [x, y, d, d]
    centre_inner = [x + d/2 - innerd/2, y + d/2 - innerd/2, innerd, innerd]

    top = [x, y - l/(3)**0.5, d, d]
    top_inner = [x, y - l/(3)**0.5, innerd, innerd]

    top[0] = x + r*cos(radians(angle))
    top[1] = y + r*sin(radians(angle))
    top_inner[0] = x + d/2 - innerd/2 + r*cos(radians(angle))
    top_inner[1] = y + d/2 - innerd/2 + r*sin(radians(angle))

    left = [x - l/2, y + l/(2*(3)**0.5), d, d]
    left_inner = [x, y - l/(3)**0.5, innerd, innerd]

    left[0] = x + r*cos(radians(angle - 120))
    left[1] = y + r*sin(radians(angle - 120))
    left_inner[0] = x + d/2 - innerd/2 + r*cos(radians(angle - 120))
    left_inner[1] = y + d/2 - innerd/2 + r*sin(radians(angle - 120))

    right = [x + l/2, y + l/(2*(3)**0.5), d, d]
    right_inner = [x, y - l/(3)**0.5, innerd, innerd]

    right[0] = x + r*cos(radians(angle + 120))
    right[1] = y + r*sin(radians(angle + 120))
    right_inner[0] = x + d/2 - innerd/2 + r*cos(radians(angle + 120))
    right_inner[1] = y + d/2 - innerd/2 + r*sin(radians(angle + 120))

    # Drawing shapes on Pygame Window
    pygame.draw.line(display, dark_color, (top[0] + d/2, top[1] + d/2), (centre[0] + d/2, centre[1] + d/2), lw)
    pygame.draw.line(display, dark_color, (left[0] + d/2, left[1] + d/2), (centre[0] + d/2, centre[1] + d/2), lw)
    pygame.draw.line(display, dark_color, (right[0] + d/2, right[1] + d/2), (centre[0] + d/2, centre[1] + d/2), lw)
    pygame.draw.ellipse(display, color, tuple(centre))
    pygame.draw.ellipse(display, dark_color, tuple(centre_inner))
    pygame.draw.ellipse(display, color, tuple(top))
    pygame.draw.ellipse(display, dark_gray, tuple(top_inner), 10)
    pygame.draw.ellipse(display, color, tuple(left))
    pygame.draw.ellipse(display, dark_gray, tuple(left_inner), 10)
    pygame.draw.ellipse(display, color, tuple(right))
    pygame.draw.ellipse(display, dark_gray, tuple(right_inner), 10)

# Displaying Information on Pygame Window
def show_info(friction, speed):
    font = pygame.font.SysFont("Times New Roman", 18)
    frictionText = font.render("Friction : " + str(friction), True, white)
    speedText = font.render("Rate of Change of Angle : " + str(speed), True, white)
    display.blit(speedText, (15, 15))
    display.blit(frictionText, (15, 45))

# The Main Function
def spinner():
    spin = True

    angle = 0

    speed = 0.0
    friction = 0.03
    rightPressed = False
    leftPressed = False

    direction = 1
    color = [[red, dark_red], [blue, dark_blue], [yellow, dark_yellow], [green, dark_green], [orange, dark_orange]]
    index = 0

    while spin:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                close()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_q:
                    close()
                if event.key == pygame.K_RIGHT:
                    rightPressed = True
                    direction = 1
                if event.key == pygame.K_LEFT:
                    leftPressed = True
                    direction = -1
                if event.key == pygame.K_SPACE:
                    index += 1
                    if index >= len(color):
                        index = 0
            if event.type == pygame.KEYUP:
                leftPressed = False
                rightPressed = False

        # Changing the Angle of rotation
        if direction == 1:
            if rightPressed:
                speed += 0.3
            else:
                speed -= friction
                if speed < 0:
                    speed = 0.0
        else:
            if leftPressed:
                speed -= 0.3
            else:
                speed += friction
                if speed > 0:
                    speed = 0.0

        display.fill(background)

        angle += speed

        # Displaying Information and the Fidget Spinner
        show_spinner(angle, color[index][0], color[index][1])
        show_info(friction, speed)

        pygame.display.update()
        clock.tick(90)

spinner()


text:
#!/bin/python3

import math
import os
import random
import re
import sys

first_multiple_input = input().rstrip().split()

n = int(first_multiple_input[0])
#print("n is: " + str(n))
m = int(first_multiple_input[1])
#print("m is " + str(m))
matrix = []

for _ in range(n):
    matrix_item = input()
    #print("matrix_item is: " + str(matrix_item))
    matrix.append(matrix_item)
    #print("matrix now is: " + str(matrix))

x = []

for i in range(m):
    for j in range(n):

        x.append(matrix[j][i])

txt = ''.join(x)

print(re.sub(r"\b[\W]+\b", " ", txt))


text:
import turtle as t

t.begin_fill()
t.fillcolor("black")

t.penup()
t.goto(-80,-200)
t.pendown()
t.left(90)

for i in range(50):
    t.right(0.1)
    t.forward(1)

t.left(90)

for i in range(50):
    t.right(1)
    t.forward(1)

for i in range(50):
    t.left(1)
    t.forward(1)

for i in range(30):
    t.right(5)
    t.forward(1)

for i in range(50):
    t.right(2)
    t.forward(1)

for i in range(50):
    t.left(2)
    t.forward(1.2)

t.left(50)

for i in range(40):
    t.right(0.5)
    t.forward(1)

t.left(90)

for i in range(100):
    t.right(1)
    t.forward(2)

t.left(90)

for i in range(50):
    t.right(1)
    t.forward(1)

t.right(90)

for i in range(38):
    t.right(1)
    t.forward(2)

t.left(90)

for i in range(40):
    t.right(2)
    t.forward(3)

t.left(80)

for i in range(30):
    t.right(1)
    t.forward(2)

t.right(90)

for i in range(50):
    t.right(1)
    t.forward(1)

t.left(90)

for i in range(100):
    t.right(1)
    t.forward(2)

t.left(50)

for i in range(130):
    t.right(0.1)
    t.forward(1)

t.left(130)

for i in range(600):
    t.left(0.5)
    t.forward(2)

t.left(130)

for i in range(20):
    t.right(0.1)
    t.forward(1)

t.end_fill()
t.hideturtle()

t.done()


text:
"""
Program : A tic tac toe game written in Python which can be played between 2 players
Github Username : @AshishKingdom
"""

class TicTacToe:
    """
    init some variables required for this class
    """
    def __init__ (self):
        self.board = [['1','2','3'],['4','5','6'],['7','8','9']]
        self.player1 = "X"
        self.player2 = "O"
        self.game_over = False
        return

    """
    draws the current board data in a good format
    """
    def draw_board(self):
        p = 0
        print("\n\n")
        for i in self.board:
            print(f"  {i[0]} | {i[1]} | {i[2]}  ")
            if p<2:
                print("-------------")
            p = p + 1
        print()
        return

    def set_value(self, position, t):
        for b in self.board:
            for i in range(0,3):
                if b[i]==position:
                    b[i] = t
                    return True

        # if player enters wrong position
        print("Invalid Input! Please enter value between 1-9 only!")
        print("Enter your move again (1-9) : ")
        return False

    """
    plays the current game until the game gets tie or a player wins
    """
    def play(self):
        current_chance = 1 # 1-> player1 chance, -1 -> player 2 chance
        while self.game_status()==0:
            self.draw_board()
            if current_chance==1:
                cp = "X"
                print("Player 1, Enter your move (1-9) : ")
            else:
                cp = "O"
                print("Player 2, Enter your move (1-9) : ")
            while not self.set_value(input(), cp):
                pass
            current_chance = current_chance * -1 # switch between 1 and -1

        self.draw_board()
        s = self.game_status()
        if s==1:
            print("Player 1 Wins!!!")
        elif s==2:
            print("Player 2 Winns!!!")
        else:
            print("It's a TIE!!!")

    """
    returns 1 if player1 has won, 2 if player2 has won, 3 if the game has tie
    0 if the game is still in progress
    """
    def game_status(self):

        b = self.board
        for i in range(0,3): #row case
            if b[i][0]=='X' and b[i][1]=='X' and b[i][2]=='X':
                return 1
            if b[i][0]=='O' and b[i][1]=='O' and b[i][2]=='O':
                return 2

        for i in range(0,3): #column case
            if b[0][i]=='X' and b[1][i]=='X' and b[2][i]=='X':
                return 1
            if b[0][i]=='O' and b[1][i]=='O' and b[2][i]=='O':
                return 2
        #diagonal case
        if (b[0][0]=='X' and b[1][1]=='X' and b[2][2]=='X') or (b[0][2]=='X' and b[1][1]=='X' and b[2][0]=='X'):
                return 1
        if (b[0][0]=='O' and b[1][1]=='O' and b[2][2]=='O') or (b[0][2]=='O' and b[1][1]=='O' and b[2][0]=='O'):
                return 2
        #checking if their is a tie
        for i in range(0,3):
            for d in "123456789":
                if d in b[i]:
                    return 0 #one more chance is left
        return 3 # its a tie!

if __name__ == "__main__":
    game = TicTacToe()
    game.play()


text:
import numpy as np
import imageio
import scipy.ndimage
import cv2

img = "MS_DHONI.png"

def rgb2gray(rgb):
    return np.dot(rgb[...,:3],[0.2989,0.5870,0.1140])

def dodge(front,back):
    final_sketch = front*255/(255-back)
    final_sketch[final_sketch>255]=255
    final_sketch[back==255]=255
    return final_sketch.astype('uint8')

ss = imageio.imread(img)
gray = rgb2gray(ss)

i = 255-gray

blur = scipy.ndimage.filters.gaussian_filter(i,sigma =15)
r = dodge(blur,gray)

cv2.imwrite('MS_DHONI_SKETCH.png',r)


text:
# Python program for implementation of Bubble Sort

def bubbleSort(arr):
	n = len(arr)
	# optimize code, so if the array is already sorted, it doesn't need
	# to go through the entire process
	swapped = False
	# Traverse through all array elements
	for i in range(n-1):
		# range(n) also work but outer loop will
		# repeat one time more than needed.
		# Last i elements are already in place
		for j in range(0, n-i-1):

			# traverse the array from 0 to n-i-1
			# Swap if the element found is greater
			# than the next element
			if arr[j] > arr[j + 1]:
				swapped = True
				arr[j], arr[j + 1] = arr[j + 1], arr[j]

		if not swapped:
			# if we haven't needed to make a single swap, we
			# can just exit the main loop.
			return

# Driver code to test above
arr = [64, 34, 25, 12, 22, 11, 90]

bubbleSort(arr)

print("Sorted array is:")
for i in range(len(arr)):
	print("% d" % arr[i], end=" ")


text:
import random
import termcolor
from termcolor import colored
print(colored("*******************************","green"))
print(colored("*******************************","green"))
print(colored("************HANGMAN************",'blue'))
print(colored("*******************************","green"))
print(colored("*******************************","green"))
name=input(colored("ENTER THE NAME TO PLAY HANGMAN: ",'blue'))
print(colored("Hi {} welcome to HANGMAN".format(name),'red'))
print(colored("Enter 1 for play easy leval HANGMAN","yellow"))
print(colored("Enter 2 for play hard leval HANGMAN",'yellow'))
choice=input(colored('Enter the choice:','blue'))
if choice!='1' and choice!='2':
    print("Wrong input")
    exit(0)
main_list=['MOVIE','FRUIT','PROGRAMMING_LANGUAGE']
random.shuffle(main_list)
if main_list[0]=='FRUIT':
    fruit = ['APPLE', 'MANGO', 'GUAVA', 'LITCHI', 'BANANA', 'ORANGE', 'COCONUT', 'BLACKPLUM','JACKFRUIT','PINEAPPLE','BERRY' ]
    random.shuffle(fruit)
    answer = fruit[1]
    compiler_answer = list(answer)
    print(colored("Guess the name of fruit:", "green"))
elif main_list[0]=='MOVIE':
    movie = ['RACE3', 'BAGHI2', 'RAID', 'PARI', 'PARMANU', 'PADMAN', 'PADMAVAT']
    random.shuffle(movie)
    answer = movie[1]
    compiler_answer = list(answer)
    print(colored("Guess the name of movie(relise 2018):", "magenta"))

elif main_list[0]=='PROGRAMMING_LANGUAGE':
    programming_language = ['ANDROID', 'C++', 'JAVA', 'PYTHON', 'SHIFT', 'JAVASCRIPT', 'PHP', 'HTML', 'KOTLIN', 'JSON','AJAX','JQUERY']
    random.shuffle(programming_language)
    answer = programming_language[1]
    compiler_answer = list(answer)
    print(colored("Guess the name of programming_language:", "blue"))

display=[]
display.extend(compiler_answer)
ex_it=1
count=0
length=len(compiler_answer)
if choice=='1':
    for i in range(len(display)):
        display[i]=" - "
    q = []
    for i in range(len(compiler_answer)):
        q.append(i)
    random.shuffle(q)
    a = q[0]
    guess=compiler_answer[a]
    guess = guess.upper()
    for i in range(len(compiler_answer)):
        if compiler_answer[i] == guess:
            display[i] = guess
            length=length-1
    print(colored("".join(display),"blue"))
    print('\n')
elif choice=='2':
    for i in range(len(display)):
        display[i]=" - "
    print(colored(''.join(display),'blue'))
    print("\n")

while count<length:
    if ex_it<=12:
        print("Chances left:", 13- ex_it)
        ex_it+=1
        guess=input(colored("Guess a letter: ",'yellow'))
        guess=guess.upper()
        for i in range(len(compiler_answer)):
            if compiler_answer[i]==guess:
                display[i]=guess
                count+=1
        print(colored("".join(display),"blue"))
        print("\n")
    else:
        print(colored("Hi {} you loose the game".format(name),'red'))
        print(colored("Play next time !","red"))
        print(colored("The answer was: {}".format(answer),'green'))
        exit(0)
print(colored("Hi {} you guess the word sucessfully".format(name),'green'))
print(colored("You won the match",'green'))


text:
list1=[]
list2=[]
num1=int(input("Enter number of elements for first list:"))
for i in range(1,num1+1):
    b=int(input("Enter element:"))
    list1.append(b)

num2=int(input("Enter number of elements for second list:"))
for i in range(1,num2+1):
    d=int(input("Enter element:"))
    list2.append(d)

list3=list1+list2
list3.sort()
print("Sorted list is:",list3)


text:
#First
# heapify tree rooted at index i

def heapify(arr, n, i):
    largest = i       # In max-heap largest is at root
    l = 2 * i + 1     # left child index = 2*i + 1
    r = 2 * i + 2     # right child index = 2*i + 2

    # See if left child of root exists and > root
    if l < n and arr[i] < arr[l]:
        largest = l

    # See if right child of root exists and > root
    if r < n and arr[largest] < arr[r]:
        largest = r

    # update root if required
    if largest != i:
        arr[i],arr[largest] = arr[largest],arr[i]  # swap

        # Heapify the root
        heapify(arr, n, largest)

# heap sort definition
def heapSort(arr):
    n = len(arr)

    for i in range(n // 2 - 1, -1, -1):
        heapify(arr, n, i)

    # extracting elements
    for i in range(n-1, 0, -1):
        arr[i], arr[0] = arr[0], arr[i]   # swap
        heapify(arr, i, 0)

arr = [ 12, 11, 13, 5, 6, 7]
heapSort(arr)
n = len(arr)
print ("Sorted array is")
for i in range(n):
    print ("%d" %arr[i])


text:
# Returns index of x in arr if present, else -1
def binary_search(arr, low, high, x):
    # Check base case
    if high >= low:

        mid = (high + low) // 2

        # If element is present at the middle itself
        if arr[mid] == x:
            return mid

            # If element is smaller than mid, then it can only
        # be present in left subarray
        elif arr[mid] > x:
            return binary_search(arr, low, mid - 1, x)

            # Else the element can only be present in right subarray
        else:
            return binary_search(arr, mid + 1, high, x)

    else:
        # Element is not present in the array
        return -1

# Test array
arr = list(map(int, input().split()))

if binary_search(arr, 0, len(arr) - 1, int(input())) != -1:
    print("Element is present at index", str(result))
else:
    print("Element is not present in array")


text:
import cv2
import datetime
import pyttsx3
import winsound
engine=pyttsx3.init()
def talk(text):
    engine.say(text)
    engine.runAndWait()
cam=cv2.VideoCapture(0)

while cam.isOpened():
    ret,frame1=cam.read()
    #compairing two frames to detect any motion in new frame with the help of new frame
    original_frame=frame1.copy()

    ret,frame2=cam.read()

    diff=cv2.absdiff(frame1,frame2)

    # diif showing colourful oytput,which may leads to error,so converted it to gray in nest step
    gray=cv2.cvtColor(diff,cv2.COLOR_RGB2GRAY)

    blur=cv2.GaussianBlur(gray,(5,5),0)

    # TO GET RID OF NOISE IN AN IMAGE USE THRESHOLD
    threshold,thresh=cv2.threshold(blur,20,255,cv2.THRESH_BINARY)

    # USING DILATED T ENHANCE THE IMAGE
    dilated=cv2.dilate(thresh,None,iterations=3)

    #YOU CAN SAY THAT TO DETECT EDGES
    contours, _ = cv2.findContours(dilated,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    #cv2.drawContours(frame1,contours,-1,(0,255,0),2)
    for c in contours:
        if cv2.contourArea(c)<5000:
            continue
        x,y,w,h=cv2.boundingRect(c)
        cv2.rectangle(frame1,(x,y),(x+w,y+h),(0,255,0),2)
        time_stamp=datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
        file_name=f"intruder-{time_stamp}.png"
        winsound.Beep(500,200)
        talk("stay away from my laptop")
        #winsound.PlaySound("alert.wav",winsound.SND_ASYNC)
        cv2.imwrite(file_name,original_frame)
    if cv2.waitKey(10)==ord("q"):
        break
    cv2.imshow("be sure",frame1)


text:
import random

movies=['anand','drishyam','nayakan','anbe sivam','gol maal','vikram vedha','black friday','dangal','manichithrathu','taare zameen par']

def create_question(movie):
    n=len(movie)
    letter=list(movie)
    temp=[]
    for i in range(n):
        if letter[i]==' ':
            temp.append(' ')
        else:
            temp.append('*')
    qn=''.join(str(x) for x in temp)
    return qn

def is_present(letter, movie):
    c=movie.count(letter)
    if c==0:
        return False
    else:
        return True

def unlock(qn,movie,letter):
    ref=list(movie)
    qn_list=list(qn)
    temp=[]
    n=len(movie)
    for i in range(n):
        if ref[i]==' ' or ref[i]==letter:
            temp.append(ref[i])
        else:
            if qn_list[i]=='*':
                temp.append('*')
            else:
                temp.append(ref[i])
    qn_new=''.join(str(x) for x in temp)
    return qn_new

def play():
    p1name=input('Player 1 : Please enter your name : ')
    p2name=input('Player 2 : Please enter your name : ')
    pp1=0
    pp2=0
    turn=0
    willing=True
    while willing:
        if turn%2==0:
           #player 1
            print(p1name,'Your turn ')
            picked_movie= random.choice(movies)
            qn=create_question(picked_movie)
            print (qn)
            modified_qn=qn
            not_said=True
            while not_said:

                letter=input('Your letter : ')
                if(is_present(letter,picked_movie)):
                  #unlock
                  modified_qn=unlock(modified_qn,picked_movie,letter)
                  print(modified_qn)
                  d=input('Press 1 to guess the movie or 2 to unlock another letter ')
                  if d==1:
                      ans=input('Your answer : ')
                      if ans==picked_movie:
                          pp1=pp1+1
                          print('Correct ')
                          not_said=False
                          print(p1name,'Your score : ',pp1)
                      else:
                          print('Wrong answer : Try again !')
                else:
                  print(letter,'not found ')
            c=input('Press 1 to continue or 0 to quit : ')
            if c==0:
                print(p1name,'Your score : ',pp1)
                print(p2name,'Your score : ',pp2)
                print('Thanks for playing ')
                print('Have a nice day : ')
                willing=False

        else:
            #player 2
            print(p2name,'Your turn ')
            picked_movie= random.choice(movies)
            qn=create_question(picked_movie)
            print (qn)
            modified_qn=qn
            not_said=True
            while not_said:

                letter=input('Your letter : ')
                if(is_present(letter,picked_movie)):
                  #unlock
                  modified_qn=unlock(modified_qn,picked_movie,letter)
                  print(modified_qn)
                  d=input('Press 1 to guess the movie or 2 to unlock another letter ')
                  if d==1:
                      ans=input('Your answer : ')
                      if ans==picked_movie:
                          pp2=pp2+1
                          print('Correct ')
                          not_said=False
                          print(p2name,'Your score : ',pp2)
                      else:
                          print('Wrong answer : Try again !')
                else:
                  print(letter,'not found ')
            c=int(input('Press 1 to continue or 0 to quit : '))
            if c==0:
                print(p1name,'Your score : ',pp1)
                print(p2name,'Your score : ',pp2)
                print('Thanks for playing ')
                print('Have a nice day : ')
                willing=False

        turn=turn+1

play()


text:
text = input("Enter something: ")
from PIL import Image, ImageDraw, ImageFont
import numpy as np
myfont = ImageFont.truetype("verdanab.ttf", 12)
size = myfont.getsize(text)
img = Image.new("1",size,"black")
draw = ImageDraw.Draw(img)
draw.text((0, 0), text, "white", font=myfont)
pixels = np.array(img, dtype=np.uint8)
chars = np.array([' ','#'], dtype="U1")[pixels]
strings = chars.view('U' + str(chars.shape[1])).flatten()
print( "\n".join(strings))


text:
# -*- coding: utf-8 -*-
"""
Created on Sun Oct  3 14:28:55 2021

@author: VISHAKHA V
"""
def shell_sort(arr, n):
    g = n // 2
    while g > 0:
        for i in range(g, n):
            temp = arr[i]
            j = i
            while j >= g and arr[j - g] > temp:
                arr[j] = arr[j - g]
                j =j-g

            arr[j] = temp
        g=g//2

arr = []
print("Enter the number of elements")
n=int(input())
print("Enter the elements:")
for i in range(n):
    ele=int(input())
    arr.append(ele)
print("Before sorting:")
print(arr)
shell_sort(arr,n)
print('After sorting:')
print(arr)


text:
from time import sleep

input("Enter any name: ")
input("Enter any number: ")
sum = input("2 + 2 = ? ")
if sum != "4":
    print("ayo what?")
else:
    print("Calculating the big sum, please wait...")
    sleep(20)
    print(";)")


text:
import turtle as t

t.penup()
t.goto(-20,230)
t.pendown()
t.left(45)

t.begin_fill()
t.fillcolor("#F1502F")
for j in range(4):
    for i in range(45):
        t.right(2)
        t.forward(1)
    t.forward(300)
t.end_fill()

t.penup()
t.goto(-70,180)
t.pendown()
t.pensize(20)
t.pencolor("white")
t.right(90)
t.forward(100)
t.pensize(50)
t.forward(1)
t.pensize(20)
t.forward(130)
t.pensize(50)
t.forward(1)
t.penup()
t.goto(0,100)
t.pendown()
t.right(45)
t.pensize(20)
t.forward(200)
t.pensize(50)
t.forward(1)
t.hideturtle()
t.done()


text:
# Shivamsinghal679

import cv2
import numpy as np
import types
from google.colab.patches import cv2_imshow

# converting types to binary
def msg_to_bin(msg):
    if type(msg) == str:
        return ''.join([format(ord(i), "08b") for i in msg])
    elif type(msg) == bytes or type(msg) == np.ndarray:
        return [format(i, "08b") for i in msg]
    elif type(msg) == int or type(msg) == np.uint8:
        return format(msg, "08b")
    else:
        raise TypeError("Input type not supported")

# defining function to hide the secret message into the image
def hide_data(img, secret_msg):
    # calculating the maximum bytes for encoding
    nBytes = img.shape[0] * img.shape[1] * 3 // 8
    print("Maximum Bytes for encoding:", nBytes)
    # checking whether the number of bytes for encoding is less
    # than the maximum bytes in the image
    if len(secret_msg) > nBytes:
        raise ValueError("Error encountered insufficient bytes, need bigger image or less data!!")
    secret_msg += '#####'       # we can utilize any string as the delimiter
    dataIndex = 0
    # converting the input data to binary format using the msg_to_bin() function
    bin_secret_msg = msg_to_bin(secret_msg)

    # finding the length of data that requires to be hidden
    dataLen = len(bin_secret_msg)
    for values in img:
        for pixels in values:
            # converting RGB values to binary format
            r, g, b = msg_to_bin(pixels)
            # modifying the LSB only if there is data remaining to store
            if dataIndex < dataLen:
                # hiding the data into LSB of Red pixel
                pixels[0] = int(r[:-1] + bin_secret_msg[dataIndex], 2)
                dataIndex += 1
            if dataIndex < dataLen:
                # hiding the data into LSB of Green pixel
                pixels[1] = int(g[:-1] + bin_secret_msg[dataIndex], 2)
                dataIndex += 1
            if dataIndex < dataLen:
                # hiding the data into LSB of Blue pixel
                pixels[2] = int(b[:-1] + bin_secret_msg[dataIndex], 2)
                dataIndex += 1
            # if data is encoded, break out the loop
            if dataIndex >= dataLen:
                break

    return img

def show_data(img):
    bin_data = ""
    for values in img:
        for pixels in values:
            # converting the Red, Green, Blue values into binary format
            r, g, b = msg_to_bin(pixels)
            # data extraction from the LSB of Red pixel
            bin_data += r[-1]
            # data extraction from the LSB of Green pixel
            bin_data += g[-1]
            # data extraction from the LSB of Blue pixel
            bin_data += b[-1]
    # split by 8-Bits
    allBytes = [bin_data[i: i + 8] for i in range(0, len(bin_data), 8)]
    # converting from bits to characters
    decodedData = ""
    for bytes in allBytes:
        decodedData += chr(int(bytes, 2))
        # checking if we have reached the delimiter which is "#####"
        if decodedData[-5:] == "#####":
            break
    # print(decodedData)
    # removing the delimiter to display the actual hidden message
    return decodedData[:-5]

# defining function to encode data into Image
def encodeText():
    img_name = input("Enter image name (with extension): ")
    # reading the input image using OpenCV-Python
    img = cv2.imread(img_name)

    # printing the details of the image
    print("The shape of the image is: ", img.shape) # checking the image shape to calculate the number of bytes in it
    print("The original image is as shown below: ")
    # resizing the image as per the need
    resizedImg = cv2.resize(img, (500, 500))
    # displaying the image
    cv2_imshow(resizedImg)

    data = input("Enter data to be encoded: ")
    if (len(data) == 0):
        raise ValueError('Data is Empty')

    file_name = input("Enter the name of the new encoded image (with extension): ")
    # calling the hide_data() function to hide the secret message into the selected image
    encodedImage = hide_data(img, data)
    cv2.imwrite(file_name, encodedImage)

# defining the function to decode the data in the image
def decodeText():
    # reading the image containing the hidden image
    img_name = input("Enter the name of the Steganographic image that has to be decoded (with extension): ")
    img = cv2.imread(img_name)  # reading the image using the imread() function

    print("The Steganographic image is as follow: ")
    resizedImg = cv2.resize(img, (500, 500))    # resizing the actual image as per the needs
    cv2_imshow(resizedImg)  # displaying the Steganographic image

    text = show_data(img)
    return text

# image steganography
def steganography():
    n = int(input("Image Steganography \n1. Encode the data \n2. Decode the data \n Select the option: "))
    if (n == 1):
        print("\nEncoding...")
        encodeText()

    elif (n == 2):
        print("\nDecoding...")
        print("Decoded message is " + decodeText())

    else:
        raise Exception("Inserted value is incorrect!")

steganography()


text:
import numpy as np

problem = []

for x in range(9):
    i = input()
    l = [int(v) for v in i]
    problem.append(l)

#print(problem)

np_problem = np.array(problem)

fixed_coordinates = [] # first getting the coordinates where fixed numbers are present
empty_coordinates = []
for i , sub_array in enumerate(problem) :
    temp =  [[i , c] for c , sub_element  in enumerate(sub_array) if sub_element > 0]
    temp2 = [[i , j] for j , sub_element2 in enumerate(sub_array) if sub_element2 == 0]
    for z in temp : fixed_coordinates.append(z)
    for w in temp2 : empty_coordinates.append(w)

l , m , r  = [0 , 3 , 6] , [1 , 4 , 7] ,  [2 , 5 , 8]

avoid_dict = {idx : [] for idx in list(range(0 , len(empty_coordinates)))}

def generate_bounds(r , c) -> list:

            lower_bound_c = c if c in l else c - 1 if c in m else c - 2
            upper_bound_c = c + 3 if c in l else c + 2 if c in m else c + 1

            lower_bound_r = r if r in l else r - 1 if r in m else r - 2
            upper_bound_r = r + 3 if r in l else r + 2 if r in m else r + 1

            return [lower_bound_c , upper_bound_c , lower_bound_r , upper_bound_r]

def backtrack(return_coordinates) :

    n_r , n_c = empty_coordinates[empty_coordinates.index(return_coordinates) - 1]  # getting back element coordinates

    while [n_r , n_c] != empty_coordinates[empty_coordinates.index(return_coordinates) + 1]:

        if np_problem[n_r , n_c] != 0 :
              avoid_dict[empty_coordinates.index([n_r , n_c])].append(np_problem[n_r , n_c])

        fix_flag = False
        r , c = n_r , n_c
        for num in range(1 , 10) :

                l_b_c , u_b_c , l_b_r , u_b_r = generate_bounds(r , c)

                if all([num not in np_problem[l_b_r : u_b_r , l_b_c : u_b_c] , num not in np_problem[r , :] , num not in np_problem[: , c]]) :
                   if num not in avoid_dict.get(empty_coordinates.index([n_r , n_c])) :
                           np_problem[n_r , n_c] , fix_flag = num , True
                           break

        if fix_flag : n_r , n_c = empty_coordinates[empty_coordinates.index([n_r , n_c]) + 1]

        if not fix_flag :
              np_problem[n_r , n_c] = 0
              avoid_dict[empty_coordinates.index([n_r , n_c])].clear()
              n_r , n_c = empty_coordinates[empty_coordinates.index([n_r , n_c]) - 1]

for r in range(9) :
    for c in range(9) :

      if [r , c] not in fixed_coordinates :

        fix_flag = False

        for num in range(1 , 10) :

            l_b_c , u_b_c , l_b_r , u_b_r = generate_bounds(r , c)

            if all([num not in np_problem[l_b_r : u_b_r , l_b_c : u_b_c] , num not in np_problem[r , :] , num not in np_problem[: , c]]) :

                np_problem[r , c] , fix_flag = num , True
                break

        if not fix_flag : backtrack([r , c])

print(np_problem)


text:
import itertools
def split_cs(x,y):
    if x[0]=='l':
        y[0]=y[0]-int(x[2])
        y[1]=y[1]+int(x[2])
    elif x[0]=='r':
        y[1]=y[1]-int(x[1])
        y[0]=y[0]+int(x[1])
    else:
        pass
    return(y)


text:
def attack_cs(o,p,q):
    if (o[1]=="l"):
        if o[0]=='r':
            q[0]=q[0]+p[1]
        else:
            q[0]=q[0]+p[0]
    elif (o[1]=='r'):
         if o[0]=='r':
            q[1]=q[1]+p[1]
         else:
             q[1]=q[1]+p[0]
    else:
        pass

    return(p,q)


text:
#!/usr/bin/env python
# coding: utf-8

# In[1]:

import split
import attack
a=[1,1]
b=[1,1]
print("player 1:",a,"\nplayer 2:",b)
def calculate(x,y):
    p1=input("enter the move of player : Attack or Split:")
    if p1=='A' or p1=='a':
            l=list(input("enter the move combination to attack:").split())
            m=attack.attack_cs(l,x,y)
            x=m[0]
            y=m[1]
            for i in range(len(y)):
                if y[i]>=5:
                    y[i]=0
    elif p1=='S' or p1=='s':
            l=list(input("enter the move combination to split:").split())
            m=split.split_cs(l,x)
            x=m
    else:
        print('invalid move')

def rollover():
    global a,b
    p=int(input("enter the player number:"))
    if p==1:
        calculate(a,b)
        print("player 1:",a,"\nplayer 2:",b)
    else:
        calculate(b,a)
        print("player 1:",a,"\nplayer 2:",b)

def status(a,b):
    rollover()
    if sum(a)==0:
        print("player 2 wins")
    elif sum(b)==0:
        print("player 1 wins")
    else:
        status(a,b)
status(a,b)

# In[ ]:


text:
# Python RollOver Game ✌🤞

## Rules:

* This is a 2-player game.

* Each player begins with one finger raised on each hand.
 On a player's turn, t hey must either attack or s plit, but not both.
 To attack, a player uses one of their live hands(Hands that have
min of 1 Finger Raised) to strike an opponent's live hand. The
number of fingers on the opponent's struck hand will increase by the
number of fingers on the hand used to strike.

* To split, a player strikes their own two hands together, and transfers
raised fingers from one hand to the other as desired.
 If any hand of any player reaches exactly five fingers, then the
hand is killed, and t his is indicated by raising zero fingers (i.e. a
closed fist).

* A player may revive their own dead hand using a split, as long as
they abide by the rules f or splitting.
 However, players may not revive opponents' hands using an attack.
Therefore, a player with two dead hands can no longer play and is
eliminated from the game.

* If any hand of any player reaches five or more fingers, then it is
considered a "dead hand".

* A player wins once all opponents are eliminated i.e by each
having two dead hands at once.

## Instructions:

* The Program starts with the Player1 & Player2 having one finger
raised on both hands.

* Player 1 goes first - The Program asks for input from the user in the
form of :
a. Move
b. Combination of t he moves
( See player input section for more details )

* After Player 1 has given the input, the program asks for input from
Player 2 in the similar way.

* After each turn, the program displays the current status of hands for
both players.

* The game ends when one of t he players has dead hands. Display
which player won t he game.

### Enjoy!


text:
/*
Description - To print all subsets/power set of an array using bit manipulation

Approach - 	Iterate from 0 to (2^n)-1
			For each iteration, we will check the postion of set bits in its binary form
			if i-th bit in that number is set,then we print i-th element in the array

Time complexity - O(2^n) exponential
*/

#include<iostream>
using namespace std;

// Function to print the subsets
void printallsubsets(int* arr,int n){
	int total_length = 1<<n;               //To find total number of subsets,bit left shift is used to find power of 2.
	for (int i=0;i<total_length;i++){

		int j = i;
		int p = 0;                        //This is used to track the position of set bits in the number
		while (j!=0){

			if (j&1<<0) cout<<arr[p];      //Check if last bit is set, we print the element if it is set.

			j = j>>1;                     //Bit right shift
			p++;
		}
		cout<<"\n";

	}

}

int main(){

	int length_of_the_array = 3;
	int arr[] = {1,2,3};                         //Integer array is used
	printallsubsets(arr,length_of_the_array);
}

/*
Sample input-
	array = {1,2,3}
Output-

	1
	2
	12
	3
	13
	23
	123

*Note  - one subset is empty subset
*/


text:
# Program to check whether a number is even or odd
# uses Bitwise AND operator

def isOdd(n) :

    # n&1 is 1 for odd
    return (n & 1);

# main
n = int(input("Enter a number: "));
if isOdd(n) :
    print("Odd Number")
else:
    print("Even Number");


text:
/*
Here we have created a function that returns sum of two integers.
Without using any of the arithmetic operators (+, ++, –, -, .. etc).
Sum of two bits can be obtained by performing XOR (^) of the two bits.
Carry bits can be obtained by performing AND (&) of two bits.

This approach is a simple Half Adder logic that can be used to add 2 single bits, but we can extend this logic for integers.

If x and y don’t have set bits at same position(s), then bitwise XOR (^) of x and y gives the sum of x and y.
To incorporate common set bits also, bitwise AND (&) is used. Bitwise AND of x and y gives all carry bits.

We calculate (x & y) << 1 and add it to x ^ y to get the required result.
Example:
        Input: 5,6
        Output: 11

    below is the c++ implementation for the above mentioned question
*/

#include <bits/stdc++.h>
using namespace std;

int Add(int x, int y)
{
    while (y != 0)			// Iterating untill there is no carry
    {
        // carry should be unsigned to
        // deal with -ve numbers
        // carry now contains common
        //set bits of x and y

        unsigned carry = x & y;

        // Sum of bits of x and y where at
        //least one of the bits is not set

        x = x ^ y;

        // Carry is shifted by one so that adding
        // it to x gives the required sum

        y = carry << 1;
    }
    return x;
}

// Driver code
int main()
{
    cout << Add(15, 32);
    return 0;
}


text:
/* Question:
    Given an array A containing 2*N+2 positive numbers,
    out of which 2*N numbers exist in pairs whereas the other two number occur exactly once and are distinct.
    Find the other two numbers.

    Example:
    Input:
    N = 2
    arr[] = {1, 2, 3, 2, 1, 4}
    Output:
    3 4
    Explanation:
    3 and 4 occur exactly once.
*/

#include<bits/stdc++.h>

using namespace std;

vector<int> singleNumber(vector<int> nums)
{
    // Code here.
    int xr = 0;
    for(int i=0;i<nums.size();i++)
    {
        xr^=nums[i];
    }
    int set_bit = xr & (~(xr-1));
    int x=0;
    int y=0;
    for(int i=0;i<nums.size();i++)
    {
        if(nums[i] & set_bit)
        {
            x^=nums[i];
        }
        else
        {
            y^=nums[i];
        }
    }
    vector<int> ans(2);
    ans[0]=x<y?x:y;
    ans[1]=x>y?x:y;
    return ans;
}

int main()
{
    vector<int> a = {1, 2, 3, 2, 1, 4};
    vector<int> ans = singleNumber(a);
    cout<<ans[0]<<" and "<<ans[1]<<" occur exactly once.";
}


text:
// C++ program to check if two strings
// are anagrams of each other
#include <bits/stdc++.h>
using namespace std;
#define NO_OF_CHARS 256

bool areAnagram(char* str1, char* str2)
{
	// Create a count array and initialize all values as 0
	int count[NO_OF_CHARS] = { 0 };
	int i;

	// For each character in input strings, increment count
	// in the corresponding count array
	for (i = 0; str1[i] && str2[i]; i++) {
		count[str1[i]]++;
		count[str2[i]]--;
	}

	// If both strings are of different length. Removing
	// this condition will make the program fail for strings
	// like "aaca" and "aca"
	if (str1[i] || str2[i])
		return false;

	// See if there is any non-zero value in count array
	for (i = 0; i < NO_OF_CHARS; i++)
		if (count[i])
			return false;
	return true;
}

// Driver code
int main()
{
	char str1[] = "geeksforgeeks";
	char str2[] = "forgeeksgeeks";

	// Function call
	if (areAnagram(str1, str2))
		cout << "The two strings are anagram of each other";
	else
		cout << "The two strings are not anagram of each "
				"other";

	return 0;
}


text:
#include <bits/stdc++.h>
using namespace std;

int findSingleElement(vector<int> v) {
    int _xor = 0;

    for(int i: v) _xor = _xor ^ i;

    return _xor;
}

int main() {
    vector<int> v = {1, 1, 2, 3, 3, 4, 4};
    cout<<findSingleElement(v);
    return 0;
}


text:
int matSearch (int N, int M, int matrix[][M], int x)
{
    if (x<matrix[0][0])return 0;
    for(int i=0;i<N;i++){
        if(x<matrix[i][0])return 0;
        if(x>=matrix[i][0] && i==N-1){
           for(int j=0;j<M;j++) {
               if(matrix[i][j]==x)return 1;
           }
        }
        if(x>=matrix[i][0] && x<matrix[i+1][0]){
            for(int j=0;j<M;j++) {
               if(matrix[i][j]==x)return 1;
           }
        }
    }return 0;
}


text:
#include <bits/stdc++.h>

using namespace std;
int shortestSubarray(vector<int>& nums, int k) {
    int l=INT_MAX,s=0;
    long long csum[nums.size()];
    csum[0]=(long long)nums[0];
    for(int i=1;i<nums.size();i++)
        csum[i]=(long long)(csum[i-1]+nums[i]);
    deque<int>d;
    for(int i=0;i<nums.size();i++)
    {
        if(csum[i]>=k)
            l=min(l,i+1);
        while(!d.empty() and csum[i]>=csum[d.front()]+k)
        {
            l=min(l,i-d.front());
            d.pop_front();
        }
        while(!d.empty() and csum[i]<=csum[d.back()])
            d.pop_back();
        d.push_back(i);
    }
    return l==INT_MAX?-1:l;
}
int main()
{
    vector<int>v;
    int k=3;
    v.push_back(2);
    v.push_back(-1);
    v.push_back(2);
    cout<<shortestSubarray(v,k);

    return 0;
}


text:
#include<iostream>
using namespace std;

#define SIZE 10

template<typename T>
class deque
{
  private:
  	T que[SIZE];
  	int front;
  	int rear;
  	int len;

  	bool Full()
  	{
  	  if((front==0 && rear==SIZE-1) || (front==rear+1))
  	    return(true);
  	  else
  	    return(false);
  	}

  	bool Empty()
  	{
  	  if(front == -1)
  	    return(true);
  	  else
  	    return(false);
  	}

  public:

  	deque()
  	{
  	  front = -1;
  	  rear = -1;
  	}

  	template<class F>
  	void F_Insert(F x)
  	{
  	   if(Full())
  	   {
  	     cout<<"Queue Overflow\n";
  	   }
  	   else
  	   {
  	      if(front==-1)
  	      {
  	        front = 0;
  	        rear = 0;
  	        que[front] = x;
  	      }
  	      else if(front == 0)
  	      {
  	        front = SIZE-1;
  	        que[front] = x;
  	      }
  	      else
  	        que[--front] = x;
  	   }
  	 }

  	 template<class F>
  	 void R_Insert(F x)
  	 {
  	   if(Full())
  	   {
  	     cout<<"Queue Overflow\n";
  	   }
  	   else
  	   {
  	      if(front==-1)
  	      {
  	        front = 0;
  	        rear = 0;
  	        que[front] = x;
  	      }
  	      else if(rear == SIZE-1)
  	      {
  	        rear = 0;
  	        que[rear] = x;
  	      }
  	      else
  	      {
  	        que[++rear] = x;
  	      }
  	    }
  	  }

  	  template<class F>
  	  void F_Remove()
  	  {
  	    if(Empty())
  	      cout<<"Queue Underflow\n";
  	    else
  	    {
  	      if(front == rear)
  	      {
  	        front =-1;
  	        rear = -1;
  	      }
  	      else
  	      {
  	        if(front == SIZE-1)
  	          front = 0;
  	        else
  	          front++;
  	       }
  	     }
  	   }

  	   template<class F>
  	   void R_Remove()
  	   {
  	     if(Empty())
  	       cout<<"Queue Underflow\n";
  	     else
  	     {
  	       if(front == rear)
  	       {
  	         front = -1;
  	         rear = -1;
  	       }
  	       else
  	       {
  	         if(rear == 0)
  	           rear = SIZE-1;
  	         else
  	           rear--;
  	       }
  	     }
  	    }

            template<class F>
  	    F Front_Element()
  	    {
  	      if(Empty())
  	      {
  	        cout<<"Queue Underflow\n";
  	        return -999;
  	      }
  	      return que[front];
  	    }

  	    template<class F>
  	    F Rear_Element()
  	    {
  	      if(Empty())
  	      {
  	        cout<<"Queue Underflow\n";
  	        return -999;
  	      }
  	      return que[rear];
  	    }

};

int main()
{
    deque<int> d;
    cout << "Inserting element from rear: 2\n";
    d.R_Insert<int>(2);
    cout << "Inserting element from rear: 7\n";
    d.R_Insert<int>(7);
    cout << "The rear element is "<<d.Rear_Element<int>()<<endl;
    cout << "Removing the rear element\n";
    d.R_Remove<int>();
    cout << "After removal,rear element is "<< d.Rear_Element<int>()<<endl;
    cout << "Inserting element from front: 4\n";
    d.F_Insert<int>(4);
    cout << "Inserting element from front: 18\n";
    d.F_Insert<int>(18);
    cout << "The front element is "<< d.Front_Element<int>()<<endl;
    cout <<"Removing the front element\n";
    d.F_Remove<int>();
    cout << "After removal,front element is "<< d.Front_Element<int>()<<endl;
    return 0;
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;
    for(int i = n ; i>=1 ; i--){
        for(int j = i ; j>=1 ; j--){
            cout<<"*"<<" ";
        }
        cout<<endl;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;

    for(int i = n ; i>=1 ; i--){
        for(int j = 1 ; j<=n-i; j++){
            cout<<" ";
        }

        for(int k = 1; k<=i ; k++){
                cout<<"*"<<" ";
        }
        cout<<endl;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;

    for(int i = 1 ; i<=n ; i++){
        for(int j = 1 ; j<=n-i; j++){
            cout<<" ";
        }

        for(int k = 1; k<=(2*i-1) ; k++){
            if(k !=1 && k!=2*i-1 && i !=n){
                cout<<" ";
            }
            else{
                cout<<"*";
            }
        }
        cout<<endl;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;
    for(int i = 1 ; i<=n ; i++){
        for(int j = 1 ; j<=i ; j++){
            cout<<"*"<<" ";
        }
        cout<<endl;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;

    for(int i = 1 ; i<=n ; i++){
        for(int j = 1 ; j<=n-i; j++){
            cout<<" ";
        }

        for(int k = 1; k<=i ; k++){
                cout<<"*"<<" ";
        }
        cout<<endl;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n ;
    cout<<"Enter rows:"<<" ";
    cin>>n;

    for(int i = n ; i>=1 ; i--){
        for(int j = 1 ; j<=n-i; j++){
            cout<<" ";
        }

        for(int k = 1; k<=(2*i-1) ; k++){
            if(k !=1 && k!=2*i-1 && i !=n){
                cout<<" ";
            }
            else{
                cout<<"*";
            }
        }
        cout<<endl;
    }
}


text:
#include<iostream.h>
#include<bits/stdc++.h>
using namespace std;

struct TreeNode {
  TreeNode *left,*right;
  int val;
  TreeNode(int x){
    val=x;
    left=right=null;
  }
};
bool helper(TreeNode *root,TreeNode* min, TreeNode* max){
        if(!root){
            return true;
        }
        if(min&&root->val<=min->val){
            return false;
        }
        if(max&&root->val>=max->val){
            return false;
        }
        return helper(root->left,min,root)&&helper(root->right,root,max);
    }
    bool isValidBST(TreeNode* root) {
        return helper(root,NULL,NULL);
    }

int main(){
  //call isValidBST()
}


text:
import java.io.*;
import java.util.*;

class QueueEmptyException extends Exception {
}

class QueueUsingLL<T> {

	class Node<T> {
		T data;
		Node<T> next;

		Node(T data) {
			this.data = data;
		}
	}

	private Node<T> head;
	private Node<T> tail;
	private int size = 0;

	public int size() {
		return size;
	}

	public boolean isEmpty() {
		if (size == 0) {
			return true;
		}
		return false;
	}

	public T front() throws QueueEmptyException {
		if (size == 0) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}

		return head.data;
	}

	public void enqueue(T element) {
		Node<T> newNode = new Node<T>(element);

		if (head == null) {
			head = newNode;
			tail = newNode;
		} else {
			tail.next = newNode;
			tail = newNode;
		}

		size++;
	}

	public T dequeue() throws QueueEmptyException {
		if (head == null) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}
		if (head == tail) {
			tail = null;
		}
		T temp = head.data;
		head = head.next;
		size--;
		return temp;
	}
}

class BinaryTreeNode<T> {
	T data;
	BinaryTreeNode<T> left;
	BinaryTreeNode<T> right;

	public BinaryTreeNode(T data) {
		this.data = data;
	}
}

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	public static BinaryTreeNode<Integer> takeInput() throws IOException {
		st = new StringTokenizer(br.readLine());
		int rootData = Integer.parseInt(st.nextToken());
		if (rootData == -1) {
			return null;
		}
		QueueUsingLL<BinaryTreeNode<Integer>> pendingNodes = new QueueUsingLL<BinaryTreeNode<Integer>>();
		BinaryTreeNode<Integer> root = new BinaryTreeNode<Integer>(rootData);
		pendingNodes.enqueue(root);

		while (!pendingNodes.isEmpty()) {
			BinaryTreeNode<Integer> currentNode;
			try {
				currentNode = pendingNodes.dequeue();
			} catch (QueueEmptyException e) {
				return null;
			}
			int leftChildData = Integer.parseInt(st.nextToken());
			if (leftChildData != -1) {
				BinaryTreeNode<Integer> leftChild = new BinaryTreeNode<Integer>(leftChildData);
				currentNode.left = leftChild;
				pendingNodes.enqueue(leftChild);
			}
			int rightChildData = Integer.parseInt(st.nextToken());
			if (rightChildData != -1) {
				BinaryTreeNode<Integer> rightChild = new BinaryTreeNode<Integer>(rightChildData);
				currentNode.right = rightChild;
				pendingNodes.enqueue(rightChild);
			}
		}
		return root;
	}

  public static int height(BinaryTreeNode<Integer> root) {
        if (root == null)
            return 0;

        return 1 + Math.max(height(root.left), height(root.right));
	}

  public static void inOrder (BinaryTreeNode<Integer> root, ArrayList<Integer> bst){
        if (root == null)
            return;

        inOrder(root.left, bst);
        bst.add(root.data);
        inOrder(root.right, bst);
  }

	public static boolean isBST(BinaryTreeNode<Integer> root) {
        ArrayList<Integer> bst= new ArrayList<Integer>();
        inOrder(root, bst);
        Set<Integer> set= new LinkedHashSet<Integer>(bst);
        Collections.sort(bst);

        if (set.size() < bst.size())
            return false;

        int i= 0;
        Iterator iterator = set.iterator();
        while (iterator.hasNext())
            if (!bst.get(i++).equals(iterator.next()))
                return false;

        return true;
	}

	public static int largestBSTSubtree(BinaryTreeNode<Integer> root) {
        if (root == null)
            return 0;

        int lHeight= height(root.left);
        int rHeight= height(root.right);
        boolean BST= isBST(root);

        if (Math.max(lHeight, rHeight) == lHeight && BST)
            return lHeight+1;
        else if (Math.max(lHeight, rHeight) == rHeight && BST)
            return rHeight+1;
        else if (!BST)
        	return Math.max(largestBSTSubtree(root.left), largestBSTSubtree(root.right));

        return 0;
	}

	public static void main(String[] args) throws IOException {
		BinaryTreeNode<Integer> root = takeInput();
		System.out.println(largestBSTSubtree(root));
	}

}


text:
#include <bits/stdc++.h>
using namespace std;

// Problem Link : https://leetcode.com/problems/kth-smallest-element-in-a-bst/
/*
Problem Statement :
Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree.

*/

struct TreeNode {
   int val;
   TreeNode *left;
   TreeNode *right;
   TreeNode() : val(0), left(nullptr), right(nullptr) {}
   TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
   TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

/*
Approach :
  We pass k by reference
  Do inorder traversal of tree
  if k is 0 at any time this means we have already reached kth smallest node : we simply return answer from here
  else we recur for left and right half after decrementing k
*/

void inorder(TreeNode*&T,int &k,int& ans){
    if (T==nullptr)
        return;

    inorder(T->left,k,ans);
    --k;
    if (k==0) ans=T->val;
    inorder(T->right,k,ans);
}

int kthSmallest(TreeNode* root, int k) {
    int ans;
    inorder(root,k,ans);
    return ans;
}

int main(){
  TreeNode* T = new TreeNode();
  //buildtree...
  cout<<kthSmallest(T,1)<<'\n';
}


text:
class Solution {
public:
    TreeNode* buildTree(vector<int>& in, vector<int>& post) {
        unordered_map<int, int> pos;
        int n = post.size();
        for (int i = 0; i < n; i++) {
            pos[in[i]] = i;
        }
        TreeNode* root = NULL;
        for (int i = n - 1; i >= 0; i--) {
            int num = post[i], p = pos[num];
            //cout << num << ":" << p << endl;
            TreeNode* tr = new TreeNode(num);
            if (i == n - 1) {
                root = tr;
                continue;
            }
            TreeNode* node = root, *prev = NULL;
            while (node) {
                prev = node;
                if (pos[node->val] > p) node = node->left;
                else  node = node->right;
            }
            node = tr;
            if (pos[prev->val] > p) prev->left = tr;
            else    prev->right = tr;
        }
        return root;
    }
};


text:
#include <bits/stdc++.h>
using namespace std;

struct Node {
    int data;
    Node *left, *right;
};

Node* newNode(int key)
{
    Node* temp = new Node;
    temp->left = temp->right = NULL;
    temp->data = key;
    return temp;
}

Node* insert(Node* root, int key)
{
    if (!root)
        return newNode(key);
    if (key < root->data)
        root->left = insert(root->left, key);
    else
        root->right = insert(root->right, key);
    return root;
}

int floor(Node* root, int key)
{
    if (!root)
        return INT_MAX;

    if (root->data == key)
        return root->data;

    if (root->data > key)
        return floor(root->left, key);

    /* Else, the floor may lie in right subtree
      or may be equal to the root*/
    int floorValue = floor(root->right, key);
    return (floorValue <= key) ? floorValue : root->data;
}

int main()
{

    Node* root = NULL;
    root = insert(root, 7);
    insert(root, 10);
    insert(root, 5);
    insert(root, 3);
    insert(root, 6);
    insert(root, 8);
    insert(root, 12);

    cout << floor(root, 9) << endl;
    return 0;
}


text:
import java.io.*;
import java.util.*;

class QueueEmptyException extends Exception {
}

class QueueUsingLL<T> {

	class Node<T> {
		T data;
		Node<T> next;

		Node(T data) {
			this.data = data;
		}
	}

	private Node<T> head;
	private Node<T> tail;
	private int size = 0;

	public int size() {
		return size;
	}

	public boolean isEmpty() {
		if (size == 0) {
			return true;
		}
		return false;
	}

	public T front() throws QueueEmptyException {
		if (size == 0) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}

		return head.data;
	}

	public void enqueue(T element) {
		Node<T> newNode = new Node<T>(element);

		if (head == null) {
			head = newNode;
			tail = newNode;
		} else {
			tail.next = newNode;
			tail = newNode;
		}

		size++;
	}

	public T dequeue() throws QueueEmptyException {
		if (head == null) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}
		if (head == tail) {
			tail = null;
		}
		T temp = head.data;
		head = head.next;
		size--;
		return temp;
	}
}

class BinaryTreeNode<T> {
	T data;
	BinaryTreeNode<T> left;
	BinaryTreeNode<T> right;

	public BinaryTreeNode(T data) {
		this.data = data;
	}
}

class LinkedListNode<T> {
	T data;
	LinkedListNode<T> next;

	public LinkedListNode(T data) {
		this.data = data;
	}
}

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	public static BinaryTreeNode<Integer> takeInput() throws IOException {
		st = new StringTokenizer(br.readLine());
		int rootData = Integer.parseInt(st.nextToken());
		if (rootData == -1) {
			return null;
		}
		QueueUsingLL<BinaryTreeNode<Integer>> pendingNodes = new QueueUsingLL<BinaryTreeNode<Integer>>();
		BinaryTreeNode<Integer> root = new BinaryTreeNode<Integer>(rootData);
		pendingNodes.enqueue(root);

		while (!pendingNodes.isEmpty()) {
			BinaryTreeNode<Integer> currentNode;
			try {
				currentNode = pendingNodes.dequeue();
			} catch (QueueEmptyException e) {
				return null;
			}
			int leftChildData = Integer.parseInt(st.nextToken());
			if (leftChildData != -1) {
				BinaryTreeNode<Integer> leftChild = new BinaryTreeNode<Integer>(leftChildData);
				currentNode.left = leftChild;
				pendingNodes.enqueue(leftChild);
			}
			int rightChildData = Integer.parseInt(st.nextToken());
			if (rightChildData != -1) {
				BinaryTreeNode<Integer> rightChild = new BinaryTreeNode<Integer>(rightChildData);
				currentNode.right = rightChild;
				pendingNodes.enqueue(rightChild);
			}
		}
		return root;
	}

	private static void print(LinkedListNode<Integer> temp)
	{
		while(temp != null){
			System.out.print(temp.data + " ") ;
			temp = temp.next;
		}
		System.out.println();
	}

  static LinkedListNode<Integer> arr, a1;

  public static int height(BinaryTreeNode<Integer> root) {
        if (root == null)
            return 0;

        return 1 + Math.max(height(root.left), height(root.right));
	}

  public static void atDepth(BinaryTreeNode<Integer> root, int h) {
        if (root == null)
            return;

        if (h == 0){
            if (arr == null){
            	arr= new LinkedListNode<Integer>(root.data);
                a1= arr;
            }
            else{
                arr.next= new LinkedListNode<Integer>(root.data);
                arr= arr.next;
            }
            return;
        }

        atDepth(root.left, h-1);
        atDepth(root.right, h-1);
	}

	public static ArrayList<LinkedListNode<Integer>> constructLinkedListForEachLevel(BinaryTreeNode<Integer> root){
        int h= height(root), c= 0;
        ArrayList<LinkedListNode<Integer>> tree= new ArrayList<LinkedListNode<Integer>>();

        while (c < h){
            arr= null;
            atDepth(root, c);
            tree.add(a1);
            c++;
        }
        return tree;
	}

	public static void main(String[] args) throws IOException {
		BinaryTreeNode<Integer> root = takeInput();
		ArrayList<LinkedListNode<Integer>> output = constructLinkedListForEachLevel(root);
		if(output!=null)
		{
			for(LinkedListNode<Integer> head : output){
				print(head);

			}
		}
	}

}


text:
import java.io.*;
import java.util.*;

class QueueEmptyException extends Exception {
}

class QueueUsingLL<T> {

	class Node<T> {
		T data;
		Node<T> next;

		Node(T data) {
			this.data = data;
		}
	}

	private Node<T> head;
	private Node<T> tail;
	private int size = 0;

	public int size() {
		return size;
	}

	public boolean isEmpty() {
		if (size == 0) {
			return true;
		}
		return false;
	}

	public T front() throws QueueEmptyException {
		if (size == 0) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}

		return head.data;
	}

	public void enqueue(T element) {
		Node<T> newNode = new Node<T>(element);

		if (head == null) {
			head = newNode;
			tail = newNode;
		} else {
			tail.next = newNode;
			tail = newNode;
		}

		size++;
	}

	public T dequeue() throws QueueEmptyException {
		if (head == null) {
			QueueEmptyException e = new QueueEmptyException();
			throw e;
		}
		if (head == tail) {
			tail = null;
		}
		T temp = head.data;
		head = head.next;
		size--;
		return temp;
	}
}

class BinaryTreeNode<T> {
	T data;
	BinaryTreeNode<T> left;
	BinaryTreeNode<T> right;

	public BinaryTreeNode(T data) {
		this.data = data;
	}
}

public class Main {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	public static BinaryTreeNode<Integer> takeInput() throws IOException {
		st = new StringTokenizer(br.readLine());
		int rootData = Integer.parseInt(st.nextToken());
		if (rootData == -1) {
			return null;
		}
		QueueUsingLL<BinaryTreeNode<Integer>> pendingNodes = new QueueUsingLL<BinaryTreeNode<Integer>>();
		BinaryTreeNode<Integer> root = new BinaryTreeNode<Integer>(rootData);
		pendingNodes.enqueue(root);

		while (!pendingNodes.isEmpty()) {
			BinaryTreeNode<Integer> currentNode;
			try {
				currentNode = pendingNodes.dequeue();
			} catch (QueueEmptyException e) {
				return null;
			}
			int leftChildData = Integer.parseInt(st.nextToken());
			if (leftChildData != -1) {
				BinaryTreeNode<Integer> leftChild = new BinaryTreeNode<Integer>(leftChildData);
				currentNode.left = leftChild;
				pendingNodes.enqueue(leftChild);
			}
			int rightChildData = Integer.parseInt(st.nextToken());
			if (rightChildData != -1) {
				BinaryTreeNode<Integer> rightChild = new BinaryTreeNode<Integer>(rightChildData);
				currentNode.right = rightChild;
				pendingNodes.enqueue(rightChild);
			}
		}
		return root;
	}

  public static void inOrder (BinaryTreeNode<Integer> root, ArrayList<Integer> arr){
        if (root == null)
            return;

        inOrder (root.left, arr);
        arr.add(root.data);
        inOrder (root.right, arr);
    }

    public static int binSearch(ArrayList<Integer> arr, int l, int e, int x){
        int mid;
        while (l <= e)
        {
            mid= l + (e-l)/2;
            if (arr.get(mid) == x)
                return mid;
            else if (arr.get(mid) < x)
                l= mid + 1;
            else
                e= mid - 1;
        }
        return -1;
    }

	public static void printNodesSumToS(BinaryTreeNode<Integer> root, int s) {
        if (root == null)
            return;

        ArrayList<Integer> arr= new ArrayList<Integer>();
        inOrder(root, arr);
        int e, i;

        for (i= 0 ; i < arr.size(); i++)
        {
            e= binSearch(arr, i+1, arr.size()-1, s-arr.get(i));
            if (e >= 0)
                System.out.println (arr.get(i) + " " + arr.get(e));
        }
	}

	public static void main(String[] args) throws IOException {
		BinaryTreeNode<Integer> root = takeInput();
		int s = Integer.parseInt(br.readLine());
		printNodesSumToS(root,s);
	}

}


text:
class Solution {
    public int search(int[] nums, int target) {
        int low = 0;
        int high = nums.length-1;

        while(low <=high){
        int mid = (low + high)/2;
        if(nums[mid] == target) return  mid;
        else if (target > nums[mid]){
            low = mid+1;
                }
           else if (target < nums[mid]){
            high = mid-1;
                }
        }
        return -1;
    }
}


text:
#include<bits/stdc++.h>
using namespace std;
vector < vector < int >> rotate(vector < vector < int >> & matrix) {
  int n = matrix.size();
  vector < vector < int >> rotated(n, vector < int > (n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      rotated[j][n - i - 1] = matrix[i][j];
    }
  }
  return rotated;
}

int main() {
  vector < vector < int >> arr;
  arr =  {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
  vector < vector < int >> rotated = rotate(arr);
  cout << "Rotated Image" << endl;
  for (int i = 0; i < rotated.size(); i++) {
    for (int j = 0; j < rotated[0].size(); j++) {
      cout << rotated[i][j] << " ";
    }
    cout << "\n";
  }

}


text:
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

main()
{
    int A[100][100];
    int i,j,k,n,res;
    printf("Enter the order of the matrix: \n");
    scanf("%d",&n);
    printf("\nEnter the elements of the matrix one by one: \n");
    for(i = 0 ; i < n ; i++)
    {
        for(j = 0 ; j < n ; j++)
        {
            scanf("%d",&A[i][j]);
        }
    }
    for(i = 0 ; i < n ; i++)
    {
        for(j = 0 ; j < n ; j++)
        {
            printf("%5d",A[i][j]);
        }
        printf("\n");
    }
    res = det(A,n);
    printf("%d",res);
}
int det(int A[100][100], int n)
{
    int Minor[100][100];
    int i,j,k,c1,c2;
    int determinant;
    int c[100];
    int O=1;

    if(n == 2)
    {
        determinant = 0;
        determinant = A[0][0]*A[1][1]-A[0][1]*A[1][0];
        return determinant;
    }
    else
    {
        for(i = 0 ; i < n ; i++)
        {
            c1 = 0, c2 = 0;
            for(j = 0 ; j < n ; j++)
            {
                for(k = 0 ; k < n ; k++)
                {
                    if(j != 0 && k != i)
                    {
                        Minor[c1][c2] = A[j][k];
                        c2++;
                        if(c2>n-2)
                        {
                            c1++;
                            c2=0;
                        }
                    }
                }
            }
            determinant = determinant + O*(A[0][i]*det(Minor,n-1));
            O=-1*O;
        }
    }
    return determinant;
}


text:
#include <stdio.h>

int main()
{
    int n, sum = 0;
    printf("Enter the order of the matrix: ");
    scanf("%d", &n);
    int a[n][n];
    printf("\nEnter the elements of matrix A: ");
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            scanf("%d", &a[i][j]);
        }
    }

    printf("\nMatrix A:\n");
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            printf("%d\t", a[i][j]);
        }
        printf("\n");
    }

    for (int i = 1; i <= n; i++)
    {
        sum = sum + a[i][i];
    }
    printf("The sum of diagonal elements of A is %d\n", sum);
    return 0;
}


text:
/*
C++ code to multiplication of two matrices.
Example:
Input:
n1 = 3, m1 = 2
A[][] = {{4, 8},
         {0, 2}
         {1, 6}}
n2 = 2, m2 = 2
B[][] = {{5, 2},
         {9, 4}}
Output: 92 40 18 8 59 26

Hint : column of first matrix should be equal to row of first matrix.

Time Complexity: O(N1 * M1 * M2)
Auxiliary space: O(N1*M2) for resultant.
*/
#include <iostream>
using namespace std;

int main()
{
    int arr1[10][10], arr2[10][10], mult[10][10], r1, c1, r2, c2, i, j, k;

    cout << "Enter rows and columns for first matrix: ";
    cin >> r1 >> c1;
    cout << "Enter rows and columns for second matrix: ";
    cin >> r2 >> c2;

    // If column of first matrix in not equal to row of second matrix,
    // ask the user to enter the size of matrix again.
    while (c1 != r2)
    {
        cout << "Error! column of first matrix not equal to row of second.";

        cout << "Enter rows and columns for first matrix: ";
        cin >> r1 >> c1;

        cout << "Enter rows and columns for second matrix: ";
        cin >> r2 >> c2;
    }

    // Storing elements of first matrix.
    cout << endl
         << "Enter elements of matrix 1:" << endl;
    for (i = 0; i < r1; ++i)
        for (j = 0; j < c1; ++j)
        {
            cin >> arr1[i][j];
        }

    // Storing elements of second matrix.
    cout << endl
         << "Enter elements of matrix 2:" << endl;
    for (i = 0; i < r2; ++i)
        for (j = 0; j < c2; ++j)
        {
            cin >> arr2[i][j];
        }

    // Initializing elements of matrix mult to 0.
    for (i = 0; i < r1; ++i)
        for (j = 0; j < c2; ++j)
        {
            mult[i][j] = 0;
        }

    // Multiplying matrix a and b and storing in array mult.
    for (i = 0; i < r1; ++i)
        for (j = 0; j < c2; ++j)
            for (k = 0; k < c1; ++k)
            {
                mult[i][j] += arr1[i][k] * arr2[k][j];
            }

    // Displaying the multiplication of two matrix.
    cout << endl
         << "Output Matrix: " << endl;
    for (i = 0; i < r1; ++i)
        for (j = 0; j < c2; ++j)
        {
            cout << " " << mult[i][j];
            if (j == c2 - 1)
                cout << endl;
        }

    return 0;
}


text:
#include <iostream>
using namespace std;

int main()
{
    int r, c, a[100][100], b[100][100], sum[100][100], i, j;

    cout << "Enter the number of rows: ";
    cin >> r;

    cout << "Enter the number of columns: ";
    cin >> c;

    cout << endl << "Enter the elements of 1st matrix: " << endl;

    // Get elements of first matrix entered by user.
    for (i = 0; i < r; ++i)
    {
     for (j = 0; j < c; ++j)
       {
           cin >> a[i][j];
       }
    }

    // Get elements of second matrix entered by user.
    cout << endl << "Enter the elements of 2nd matrix: " << endl;
    for (i = 0; i < r; ++i)
    {
       for (j = 0; j < c; ++j)
       {
           cin >> b[i][j];
       }
    }

    // Adding the two matrices
    for (i = 0; i < r; ++i)
    {
        for (j = 0; j < c; ++j)
        {
            sum[i][j] = a[i][j] + b[i][j];
        }
    }

    // Display the result.
    cout << endl << "Sum of the two matrix is: " << endl;
    for (i = 0; i < r; ++i)
    {
        for (j = 0; j < c; ++j)
        {
            cout << sum[i][j] << "  ";
            if (j == c - 1) {
                cout << endl;
            }
        }
    }

    return 0;
}


text:
#include<iostream>
using namespace std;
 int main()
 {
     int i, j, n, m;
     int arr[100][100], trs[100][100];
     cout << "Enter the number of rows:" << endl;
     cin >> n;
     cout << "Enter the number of colums:" << endl;
     cin >> m;
     cout << "Enter the elements of matrix:" << endl;
     for (i = 0; i < n; i++)
     {
         for(j = 0; j < m; j++)
         {
             cin >> arr[i][j];
         }
     }

     // transpose of the matrix
     for(i = 0; i < n; i++)
     {
         for(j = 0; j < m; j++)
         {
            trs[j][i] = arr[i][j];
         }
     }

     cout << "Transposed matrix:" << endl;
     for ( i = 0; i < m; i++)
     {
         for( j = 0; j < n; j++)
         {
             cout << trs[i][j] << "  ";
         }
         cout << endl;
     }

     return 0;
 }


text:
#include<iostream>
using namespace std;
int main()
{
	int rows;
	int** pp = new int*[rows];
	int* cols = new int[rows];
	int** arr = new int* [rows];
	int cols;
	for (int i = 0; i < rows; i++)
	{
		cout << "ENter number of columns for row " << i << endl;
		cin >> cols[i];
		pp[i] = new int[cols[i]];

	}
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols[i]; j++)
		{
			arr[j][i] = pp[i][j];
		}
	}
	for (int i = 0; i < rows; i++)
	{

		for (int j = 0; j < cols[i]; j++)
		{
			cout << arr[i] << " ";
		}
		cout << endl;
	}

}


text:
#include<bits/stdc++.h>
using namespace std;

 vector<vector<int>> diagonalSort(vector<vector<int>>& mat) {
        int n = mat.size()-1;
        int m = mat[0].size()-1;

         vector<pair<int,int>>arr;

        for(int j = n;j>=0;j--){
            arr.push_back({j,0});
        }
        for(int i = 1;i<=m;i++){
            arr.push_back({0,i});
        }
        vector<vector<int>>sol;
        for(auto i = 0;i<arr.size();i++){
            int x = arr[i].first;
            int y = arr[i].second;
           // cout<<x<<" "<<y<<" \n";
            vector<int>temp;
            while(x<=n && y<=m){
                temp.push_back(mat[x][y]);
                x++;
                y++;
            }
            sort(temp.begin(),temp.end());
            sol.push_back(temp);
        }

         for(auto i = 0;i<arr.size();i++){
            int x = arr[i].first;
            int y = arr[i].second;
             vector<int>c = sol[i];
             int k = 0;
            while(x<=n && y<=m && k<c.size()){
              mat[x][y] = c[k];
                x++;
                y++;
                k++;
            }
        }

        return mat;
    }

void print(vector<vector<int>>&matrix){
	for(auto x : matrix){
		for(auto y : x){
			cout<<y<<" ";
		}
		cout<<"\n";
	}
}

int main(){
    vector<vector<int>>matrix;
    int n;
    cin>>n;
    for(int i = 0;i<n;i++){
    	vector<int>temp;
    	for(int j = 0;j<n;j++){
    		int val ;
    		cin>>val;
    		temp.push_back(val);
		}
		matrix.push_back(temp);
	}
	cout<<"Before sort : \n";
	print(matrix);
	matrix = diagonalSort(matrix);
	cout<<"After Sort : \n";
	print(matrix);
	return 0;
}


text:
#include <bits/stdc++.h>
using namespace std;
// A utility function to swap two elements
void swap(int* a, int* b)
{
    int t = *a;
    *a = *b;
    *b = t;
}
int partition(int arr[], int low, int high)
{
    int pivot = arr[high]; // pivot
    int i
        = (low
           - 1); // Index of smaller element and indicates
                 // the right position of pivot found so far

    for (int j = low; j <= high - 1; j++) {
        // If current element is smaller than the pivot
        if (arr[j] < pivot) {
            i++; // increment index of smaller element
            swap(&arr[i], &arr[j]);
        }
    }
    swap(&arr[i + 1], &arr[high]);
    return (i + 1);
}
void quickSort(int arr[], int low, int high)
{
    if (low < high) {
        /* pi is partitioning index, arr[p] is now
        at right place */
        int pi = partition(arr, low, high);

        // Separately sort elements before
        // partition and after partition
        quickSort(arr, low, pi - 1);
        quickSort(arr, pi + 1, high);
    }
}

/* Function to print an array */
void printArray(int arr[], int size)
{
    int i;
    for (i = 0; i < size; i++)
        cout << arr[i] << " ";
    cout << endl;
}

int main()
{
    int arr[] = { 15,16,8,4,9,17,20};
    int n = sizeof(arr) / sizeof(arr[0]);
    quickSort(arr, 0, n - 1);
    cout << "Sorted array: \n";
    printArray(arr, n);
    return 0;
}
/*OUTPUT:
4 8 9 15 16 17 20 */


text:
#include<iostream>
#include<vector>
using namespace std;

void swap(int *A, int i, int j) {
          int temp = A[i];
          A[i] = A[j];
          A[j] = temp;
}

int findMinIndex(vector<int> &A, int start) {
    int min_index = start;

    ++start;

    while(start < (int)A.size()) {
        if(A[start] < A[min_index])
            min_index = start;

        ++start;
    }

    return min_index;
}

void selectionSort(vector<int> &A) {
    for(int i = 0; i < (int)A.size(); ++i) {
        int min_index = findMinIndex(A, i);

        if(i != min_index)
            swap(A[i], A[min_index]);
    }
}

int main()
{
    vector<int> A = {5, 2, 6, 7, 2, 1, 0, 3};

    selectionSort(A);
    for(int num : A)
        cout << num << ' ';

    return 0;
}


text:
// Shell Sort in C programming

#include <stdio.h>

// Shell sort
void shellSort(int array[], int n) {
  // Rearrange elements at each n/2, n/4, n/8, ... intervals
  for (int interval = n / 2; interval > 0; interval /= 2) {
    for (int i = interval; i < n; i += 1) {
      int temp = array[i];
      int j;
      for (j = i; j >= interval && array[j - interval] > temp; j -= interval) {
        array[j] = array[j - interval];
      }
      array[j] = temp;
    }
  }
}

// Print an array
void printArray(int array[], int size) {
  for (int i = 0; i < size; ++i) {
    printf("%d  ", array[i]);
  }
  printf("\n");
}

// Driver code
int main() {
  int data[] = {9, 8, 3, 7, 5, 6, 4, 1};
  int size = sizeof(data) / sizeof(data[0]);
  shellSort(data, size);
  printf("Sorted array: \n");
  printArray(data, size);
}


text:
#include<iostream>
using namespace std;
int* temp(int arr[], int size);
int main()
{
	int rows;
	cin >> rows;
	int** pp = new int* [rows];
	int cols ;
	for (int i = 0; i < rows; i++)
	{
		cout << "Enter number of columns for row " << i << endl;
		cin >> cols;
		pp[i] = new int[cols];
	}
	cout << "ENter array elements\n";
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols; j++)
		{
			cin >> pp[i][j];
		}
	}
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols; j++)
		{
			cout << pp[i][j];
		}
	}

	return 0;
}

int* sort(int arr[], int s)
{
	int temp;
	for (int i = 0; i < s; i++)
	{
		for (int j = 0; j < s; j++)
		{
			if (arr[i] > arr[j])
			{
				temp = arr[i];
				arr[i] = arr[j];
				arr[j] = temp;
			}
		}
	}
	return arr;
}


text:
// C++ program to sort an
// array using bucket sort
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

// Function to sort arr[] of
// size n using bucket sort
void bucketSort(float arr[], int n)
{

	// 1) Create n empty buckets
	vector<float> b[n];

	// 2) Put array elements
	// in different buckets
	for (int i = 0; i < n; i++) {
		int bi = n * arr[i]; // Index in bucket
		b[bi].push_back(arr[i]);
	}

	// 3) Sort individual buckets
	for (int i = 0; i < n; i++)
		sort(b[i].begin(), b[i].end());

	// 4) Concatenate all buckets into arr[]
	int index = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < b[i].size(); j++)
			arr[index++] = b[i][j];
}

/* Driver program to test above function */
int main()
{
	float arr[]
		= { 0.897, 0.565, 0.656, 0.1234, 0.665, 0.3434 };
	int n = sizeof(arr) / sizeof(arr[0]);
	bucketSort(arr, n);

	cout << "Sorted array is \n";
	for (int i = 0; i < n; i++)
		cout << arr[i] << " ";
	return 0;
}


text:
#include<bits/stdc++.h>

using namespace std;

struct Node
{
	int key;
	struct Node *left, *right;
};

struct Node *newNode(int item)
{
	struct Node *temp = new Node;
	temp->key = item;
	temp->left = temp->right = NULL;
	return temp;
}

void storeSorted(Node *root, int arr[], int &i)
{
	if (root != NULL)
	{
		storeSorted(root->left, arr, i);
		arr[i++] = root->key;
		storeSorted(root->right, arr, i);
	}
}

Node* insert(Node* node, int key)
{

	if (node == NULL) return newNode(key);

	if (key < node->key)
		node->left = insert(node->left, key);
	else if (key > node->key)
		node->right = insert(node->right, key);

	return node;
}

void treeSort(int arr[], int n)
{
	struct Node *root = NULL;

	root = insert(root, arr[0]);
	for (int i=1; i<n; i++)
		root = insert(root, arr[i]);

	int i = 0;
	storeSorted(root, arr, i);
}

int main()
{
	int arr[] = {5, 4, 7, 2, 11};
	int n = sizeof(arr)/sizeof(arr[0]);

	treeSort(arr, n);

		for (int i=0; i<n; i++)
	cout << arr[i] << " ";

	return 0;
}


text:
#include<iostream>
using namespace std;
int main()
{
	int rows ;
	cin >> rows;
	int** pp = new int* [rows];
	int* cols = new int[rows];
	for (int i = 0; i < rows; i++)
	{
		cout << "Enter number of columns for row " << i << endl;
		cin >> cols[i];
		pp[i] = new int[cols[i]];
	}
	cout << "ENter array elements\n";
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols[i]; j++)
		{
			cin>>pp[i][j];
		}
	}
	int temp = 0;
	for (int i = 0; i < rows; i++)
	{

		for (int j = 0; j < cols[i]; j++)
		{

			for (int k = 0; k < cols[i] - j - 1; k++)
			{
				if (pp[i][k] > pp[i][k + 1])
				{
					temp = pp[i][k];
					pp[i][k] = pp[i][k + 1];
					pp[i][k + 1] = temp;
				}
			}
		}
	}
	for (int i = 0; i < rows; i++)
	{
		for (int j = 0; j < cols[i]; j++)
		{
			cout<< pp[i][j]<<" ";
		}
		cout << endl;
	}
	return 0;
}


text:
#include<bits/stdc++.h>

using namespace std;
void insertion_sort(int arr[], int n) {

  for (int i = 1; i < n; i++) {
    int current = arr[i];
    int j = i - 1;
    while (j >= 0 && arr[j] > current) {
      //swap
      arr[j + 1] = arr[j];
      j--;
    }
    arr[j + 1] = current;
  }
  cout << "After insertion sort:" << "\n";
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";

}
int main() {
  int arr[] = {13,46,24,52,20,9};
  int n = sizeof(arr) / sizeof(arr[0]);
  cout << "Before insertion sort:" << "\n";
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
  insertion_sort(arr, n);
  return 0;
}


text:
#include<iostream>

using namespace std;

// A function to swap values using call by reference.
void swap(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
}

// A function implementing shaker sort.
void ShakerSort(int a[], int n)
{
	int i, j, k;
	for(i = 0; i < n;)
	{
		// First phase for ascending highest value to the highest unsorted index.
		for(j = i+1; j < n; j++)
		{
			if(a[j] < a[j-1])
				swap(&a[j], &a[j-1]);
		}
		// Decrementing highest index.
		n--;

		// Second phase for descending lowest value to the lowest unsorted index.
		for(k = n-1; k > i; k--)
		{
			if(a[k] < a[k-1])
				swap(&a[k], &a[k-1]);
		}
		// Incrementing lowest index.
		i++;
	}
}

int main()
{
	int n, i;
	cout<<"\nEnter the number of data element to be sorted: ";
	cin>>n;

	int arr[n];
	for(i = 0; i < n; i++)
	{
		cout<<"Enter element "<<i+1<<": ";
		cin>>arr[i];
	}

	ShakerSort(arr, n);

	// Printing the sorted data.
	cout<<"\nSorted Data ";
	for (i = 0; i < n; i++)
		cout<<"->"<<arr[i];

	return 0;
}