Linear Search using Python

”’
Created on Oct 14, 2018
Linear Search using Python
@author: asharda
”’
arr = [10, 20, 30]
for x in arr:
if(x == 10):
print(“Number is found”)
break
else:
print(“Number is not found”)

Advertisements
Posted in Python, Uncategorized | Leave a comment

File Handling using Python

file_name=input(“Enter file name”)
file_n=open(file_name,”r”)
strings=file_n.read()
print(strings)
file_n.close()

Posted in Python, Uncategorized | Leave a comment

GCD using Python

”’
Created on Oct 12, 2018

@author: asharda
”’
from fractions import gcd
gcd_p=gcd(12,8)
print(gcd_p)

Posted in Data Structures, Python, Uncategorized | Leave a comment

Factorial in Python

”’
Created on Oct 12, 2018

@author: asharda
”’
def factorial(n):
if(n==1):
return 1
return factorial(n-1)*n

print(factorial(6))

Posted in Python, Uncategorized | Leave a comment

Queue in Java

package test5;

import java.util.LinkedList;

/**
* Queues using LinkedList
* @author asharda
*
*/
public class Queues {

LinkedList<Integer> list=new LinkedList<Integer>();

/**
* Enqueue
* @param data
*/
public void enqueue(int data)
{
list.add(data);

}

/**
* Dequeue
* @return Integer
*/
public Integer dequeue()
{
return list.removeFirst();
}

/**
* Display Queue contents
*/
public void display()
{
list.forEach(System.out::println);
}
/**
* @param args
*/
public static void main(String[] args) {

Queues q=new Queues();
q.enqueue(10);
q.enqueue(20);
q.display();
q.dequeue();
q.display();

}

}

Posted in Data Structures, Java, Java 8, Uncategorized | Leave a comment

Stack using LinkedList in Java

package test5;
import java.util.LinkedList;

/**
* Stack using LinkedList
* @author asharda
*
*/
public class Stack {

LinkedList<Integer> list=new LinkedList<Integer>();

/**
* Push Operation
* @param data
*/
public void push(int data)
{
list.addFirst(data);
}

/**
* Display contents of stack
*/
public void display()
{
list.forEach(System.out::println);
}

/**
* Pop from stack
* @return Integer
*/
public Integer pop()
{
return list.removeFirst();
}

public static void main(String[] args) {
Stack st=new Stack();
st.push(10);
st.push(20);
st.display();
System.out.println(“Number popped is “+st.pop());
st.display();

}

}

Posted in Data Structures, Java, Java 8, Uncategorized | Leave a comment

$ is synonym for JQuery

$ is synonym for JQuery.You can use $(‘p’) or jQuery(‘p’) alternatively.

Posted in Uncategorized | Leave a comment