Professional Documents
Culture Documents
Exp11 15
Exp11 15
Exp11 15
import java.util.*;
import java.io.*;
try
String[] arrayList;
String a;
System.out.println("KEY : VALUE");
while (sc.hasNext())
a = sc.nextLine();
arrayList = a.split("\\s+");
ht.put(arrayList[0], arrayList[1]);
}
System.out.println("Welcome to St. Martin's EngineeringTO KG REDDY Eng College");
opt = s.next();
switch (opt)
case "1":
System.out.println("Enter Name");
name = s.next();
if (ht.containsKey(name))
else
System.out.println("Not Found");
}
}
break;
case "2":
System.out.println("Enter mobile");
mobile = s.next();
if (ht.containsValue(mobile))
if (mobile.equals(e.getValue()))
else
System.out.println("Not Found");
break;
case "3":
opt = "3";
System.out.println("Menu Successfully Exited");
break;
default:
break;
System.out.println(ex.getMessage());
Exp:12
class Q
int n;
if(!valueSet) try
wait();
}
catch(InterruptedException e)
System.out.println("Got:"+n); valueSet=false;
notify(); return n;
if(valueSet) try
wait();
catch(InterruptedException e)
this.n=n; valueSet=true;
System.out.println("Put:"+n); notify();
Q q; Producer(Q q)
{
this.q=q;
new Thread(this,"Producer").start();
q.put(i++);
Q q; Consumer(Q q)
this.q=q;
new Thread(this,"Consumer").start();
while(true)
q.get();
}
}
class ProdCons
Exp13
// import statement
import java.io.File;
if(i == a.length)
return;
System.out.println(a[i].getName());
printFileNames(a, i + 1, lvl);
// Main Method
// display statements
System.out.println("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =");
System.out.println("= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =");
// Calling the method
obj.printFileNames(a, 0, 0);
Exp:14
import java.util.*;
class Main {
i++;
numArray[i] = numArray[j];
numArray[j] = temp;
numArray[i + 1] = numArray[high];
numArray[high] = temp;
return i + 1;
//auxillary stack
intStack[++top] = low;
intStack[++top] = high;
// Pop h and l
high = intStack[top--];
low = intStack[top--];
// Set pivot element at its correct position
// in sorted array
intStack[++top] = low;
intStack[++top] = pivot - 1;
intStack[++top] = pivot + 1;
intStack[++top] = high;
quickSort(numArray, 0, n - 1);