Thursday, October 19, 2023

Oracle Cloud Infrastructure Q n A

 Different types of compute instances available in OCI:

  • General purpose
  • Compute optimized
  • Memory optimized
  • Accelerated computing
  • Bare metal

Different types of storage available in OCI:

  • Block storage
  • Object storage
  • File storage
  • Archive storage

Different types of networking resources available in OCI:

  • Virtual cloud networks (VCNs)
  • Subnets
  • Security lists
  • Route tables
  • Gateways
  • Load balancers

Different types of databases available in OCI:

  • Autonomous Database
  • Database Service for Oracle Database
  • Database Service for MySQL
  • Database Service for PostgreSQL
  • Database Service for NoSQL

Different types of analytics and AI services available in OCI:

  • Analytics Cloud
  • AI Platform
  • Data Science Workbench
  • Data Catalog
  • Databricks in OCI

Different types of app development services available in OCI:

  • Container Engine for Kubernetes (OKE)
  • Cloud Native Applications Platform (CNAP)
  • Functions
  • API Gateway
  • Service Mesh
  • Mobile Backend as a Service (MBaaS)

Different types of security and compliance services available in OCI:

  • Identity and Access Management (IAM)
  • Key Management
  • Security Zones
  • Security Audit and Monitoring
  • Data Governance
  • Compliance

Different types of identity and access management services available in OCI:

  • Identity and Access Management (IAM)
  • Identity Cloud Service (IDCS)
  • Unified Directory
  • Access Management
  • Identity Analyzer

Different types of observability and management services available in OCI:

  • Monitoring
  • Logging
  • Analytics
  • Notifications
  • Cost Management
  • Resource Manager

Different types of hybrid offerings available in OCI:

  • Dedicated Region Cloud@Customer
  • Managed Cloud@Customer
  • Oracle Cloud VMware Engine
  • Oracle Cloud Exadata Cloud Service
  • Oracle Cloud Infrastructure FastConnect

A boot volume is a type of block volume that is used to boot a compute instance. It contains the operating system and all of the files required to start the instance. A block volume is a general-purpose storage device that can be used to store any type of data.

Boot volumes are typically smaller than block volumes, as they only need to contain the operating system and boot files. They are also typically configured to be more performant than block volumes, as they need to be able to quickly read and write data during the boot process.

Block volumes can be of any size and can be used to store any type of data, including operating systems, databases, applications, and user files. They are typically less expensive than boot volumes, but they may not be as performant.

Use cases for boot volumes:

  • Booting a compute instance with an operating system
  • Creating a bootable image for a compute instance
  • Recovering a compute instance from a backup

Use cases for block volumes:

  • Storing an operating system for a compute instance
  • Storing data for a database or application
  • Storing user files
  • Creating a snapshot of a volume for backup or recovery

Example:

You can use a boot volume to install an operating system on a compute instance. Once the operating system is installed, you can use the boot volume to boot the instance. You can also use a boot volume to create a bootable image for a compute instance. This can be useful for quickly deploying multiple instances with the same operating system and configuration.

You can use a block volume to store data for a database or application. You can also use a block volume to store user files. Block volumes can be attached to multiple compute instances, so you can share data between instances. You can also create a snapshot of a block volume for backup or recovery.



A public IP address is a unique IP address that is assigned to your network router by your internet service provider (ISP). It is used to identify your router and your devices on the internet.

A private IP address is a unique address that is assigned to a device on a local network. It is used to identify the device within that network.

Use cases for public IP addresses:

  • Hosting a website or web server
  • Playing online games
  • Using remote desktop software to access a computer on your home network from outside of your home

Use cases for private IP addresses:

  • Connecting to a printer on a local network
  • Sharing files between devices on a local network
  • Playing multiplayer games on a local network

Example:

When you visit a website, your computer sends a request to the website's server. The server then sends back the website's content to your computer. In order for the server to know where to send the website's content, it needs to know your computer's IP address.

If your computer has a public IP address, the server can send the website's content directly to your computer. However, if your computer has a private IP address, the server will not be able to send the website's content directly to your computer. Instead, the server will send the website's content to your router. Your router will then forward the website's content to your computer.

This process is called network address translation (NAT). NAT is used to allow multiple devices on a local network to share a single public IP address.


differences between NAT gateways and load balancers:

NAT gateway is a managed network service that allows instances in a private subnet to access the internet. It does this by translating the private IP addresses of the instances to a single public IP address. This allows the instances to send and receive traffic from the internet, even though they do not have their own public IP addresses.

A load balancer is a device or software that distributes traffic across multiple servers. This can help to improve performance, reliability, and scalability. Load balancers can be used to distribute traffic between web servers, application servers, and database servers.

Use cases for NAT gateways:

  • Allowing instances in a private subnet to access the internet
  • Providing internet access to devices on a local network

Use cases for load balancers:

  • Distributing traffic across multiple web servers
  • Distributing traffic across multiple application servers
  • Distributing traffic across multiple database servers
  • Improving performance, reliability, and scalability of applications

Example:

A company has a website that is hosted on two web servers in a private subnet. The company wants to allow users to access the website from the internet. The company can use a NAT gateway to translate the private IP addresses of the web servers to a single public IP address. This will allow users to access the website by visiting the public IP address in a web browser.

The company could also use a load balancer to distribute traffic between the two web servers. This would help to improve performance and reliability. If one web server goes down, the load balancer will continue to distribute traffic to the other web server.

Conclusion:

NAT gateways and load balancers are both network devices that can be used to improve the performance, reliability, and scalability of applications. However, they have different purposes. NAT gateways are used to allow instances in a private subnet to access the internet, while load balancers are used to distribute traffic across multiple servers



database instance and a database cluster


eatureDatabase InstanceDatabase Cluster
DefinitionA single running instance of a DBMSA group of database instances that work together as a single system
PurposeTo store, manage, and access dataTo improve performance, scalability, and high availability
ScalabilityLimited to the resources of a single serverCan be scaled up or down by adding or removing database instances
AvailabilityCan be unavailable if the server failsCan remain available even if one or more database instances fail



 some examples of database clusters:

  • A cluster of web servers that use a database to store user data
  • A cluster of database servers that support a large online transaction processing (OLTP) system
  • A cluster of database servers that store and analyze big data


differences between VCNs and subnets:

VCNs and subnets are essential components for creating secure and scalable networks in OCI.

A virtual cloud network (VCN) is a software-defined network that you create and manage in Oracle Cloud Infrastructure (OCI). A VCN is isolated from other VCNs and the public internet, which provides security and control over your network traffic.

A subnet is a subdivision of a VCN. Subnets are used to organize your resources within a VCN and to control network traffic between them. You can create multiple subnets in a VCN, each with its own range of IP addresses.

differences between VCNs and subnets:

FeatureVCNSubnet
DefinitionA software-defined network that you create and manage in OCIA subdivision of a VCN
PurposeTo isolate your resources from other VCNs and the public internetTo organize your resources within a VCN and to control network traffic between them
SizeA VCN can have up to 100 subnetsA subnet can have up to 4 billion IP addresses
ScopeA VCN is global to a regionA subnet is regional



security list and a network access control list (NACL)?



A security list and a network access control list (NACL) are both firewall-like features that can be used to control traffic in and out of a network. However, there are some key differences between the two.

Scope

  • A security list is associated with an instance, while a NACL is associated with a subnet. This means that a security list controls traffic to and from a specific instance, while a NACL controls traffic to and from all instances in a subnet.

Rules

  • Security list rules can be used to allow or deny traffic based on the source IP address, destination IP address, port number, and protocol. NACL rules can also be used to allow or deny traffic based on the same criteria, but they can also be used to block specific IP addresses or ports.

Statefulness

  • Security lists are stateful, meaning that they keep track of the state of connections and allow traffic in both directions for established connections. NACLs are stateless, meaning that they only evaluate traffic based on the individual packets, not the state of the connection.

Use cases

  • Security lists are typically used to control traffic to and from specific instances, such as web servers or database servers. NACLs are typically used to control traffic to and from all instances in a subnet, such as a subnet that contains public-facing web servers.

What is the difference between a database role and a database user?

A database role is a logical grouping of permissions that can be assigned to database users. A database user is an individual user account that can be used to access a database.

Roles can be used to simplify permission management by assigning a single role to a group of users with similar needs. For example, you could create a role for developers that gives them permission to create and modify database objects, and a role for administrators that gives them permission to manage all aspects of the database.

Users can be assigned to multiple roles, and the permissions of all roles assigned to a user are combined. For example, a user who is assigned to both the developers role and the administrators role would have all of the permissions granted to both roles.

What is the difference between a database snapshot and a database backup?

A database snapshot is a point-in-time copy of a database. A database backup is a copy of the database that is typically used to recover from data loss or corruption.

Snapshots can be used to create test environments, to back up databases before making changes, or to restore databases to a previous point in time. Snapshots can be created quickly and easily, and they can be used to restore databases to their previous state just as quickly.

Backups are typically created on a regular schedule, such as daily or weekly. They can be stored on-premises or in the cloud. Backups are used to recover from data loss or corruption, such as if a database is accidentally deleted or corrupted.

What is the difference between a database instance resize and a database instance move?

A database instance resize is the process of changing the size of a database instance. This can be done to increase or decrease the resources allocated to the instance.

A database instance move is the process of moving a database instance to a different physical or virtual machine. This can be done for a variety of reasons, such as to improve performance or to migrate the instance to a different region.

What is the difference between a load balancer and a web application firewall (WAF)?

A load balancer distributes traffic across multiple servers. This can be used to improve performance and scalability, and to ensure that applications remain available even if one server fails.

A web application firewall (WAF) protects web applications from attacks. WAFs can be used to block common web attacks, such as SQL injection and cross-site scripting.

Load balancers and WAFs can be used together to improve the performance, scalability, and security of web applications.

Wednesday, October 11, 2023

Windows services that can slow down your computer,

 

  • SuperFetch:(Sysmain) This service pre-loads frequently used programs into memory, which can improve startup times and application performance. However, it can also use up a lot of memory, especially on older computers.
  • Windows Search: This service indexes your files and folders so that you can quickly find them. However, it can also use up a lot of CPU resources, especially when it's first running.
  • Print Spooler: This service manages your printing jobs. However, it can sometimes get stuck or cause problems, which can slow down your computer.
  • OneDrive: This service syncs your files and folders between your computer and the cloud. However, it can use up a lot of CPU and network resources, especially when it's first syncing or uploading large files.
  • Other services that you don't need: There are a number of other Windows services that you may not need, such as those for games, peripheral devices, or programs that you no longer use. Disabling these services can free up resources and improve your computer's performance.

There are a number of Windows services that can slow down your computer, especially if you don't need them. Some of the most common include:

  • Superfetch: This service pre-loads frequently used programs into memory, which can improve startup times and application performance. However, it can also use up a lot of memory, especially on older computers.
  • Windows Search: This service indexes your files and folders so that you can quickly find them. However, it can also use up a lot of CPU resources, especially when it's first running.
  • Print Spooler: This service manages your printing jobs. However, it can sometimes get stuck or cause problems, which can slow down your computer.
  • OneDrive: This service syncs your files and folders between your computer and the cloud. However, it can use up a lot of CPU and network resources, especially when it's first syncing or uploading large files.
  • Other services that you don't need: There are a number of other Windows services that you may not need, such as those for games, peripheral devices, or programs that you no longer use. Disabling these services can free up resources and improve your computer's performance.

It's important to note that you should be careful about disabling Windows services. Some services are essential for the proper operation of your computer and disabling them can cause problems. If you're not sure whether or not you need a particular service, it's best to leave it enabled.

If you're experiencing performance problems, you can try disabling some of the services listed above to see if that helps. You can do this by opening the Services console (press Windows key + R and type "services.msc"). Once the Services console is open, scroll down to the service you want to disable and double-click it. In the Startup type drop-down menu, select Disabled. Click OK to save your changes.

It's also important to note that disabling services is not a permanent solution. If you need to use a service again, you can simply re-enable it following the steps above.

Here are some additional tips for speeding up your windows computer:

  • Uninstall any programs that you don't use.
  • Clean up your hard drive by deleting temporary files and other junk.
  • Defragment your hard drive.
  • Update your drivers.
  • Add more RAM.
  • Use a SSD instead of a traditional hard drive.
Reference: Google

Friday, August 25, 2023

Differences between 4G and 5G

 4G and 5G are the two most recent generations of cellular network technology. 5G is the successor to 4G, and it offers a number of significant improvements in terms of speed, latency, and capacity.

Speed: 5G is significantly faster than 4G. Theoretical peak download speeds for 5G can reach up to 10 gigabits per second (Gbps), while 4G's peak download speeds are typically around 1 Gbps. In real-world tests, 5G download speeds have been shown to be up to 20 times faster than 4G. Latency: Latency is the time it takes for a signal to travel from one point to another. 5G has much lower latency than 4G, with theoretical latency of less than 1 millisecond (ms). 4G latency is typically around 50 ms. Capacity: 5G can support more devices and data connections than 4G. This is because 5G uses a wider range of frequencies, which allows for more bandwidth. 5G is also designed to be more efficient, which means that it can support more devices without sacrificing speed or latency.

In addition to these technical improvements, 5G also offers a number of new features and capabilities that were not possible with 4G. These include:

  • Ultra-reliable low latency communication (URLLC): URLLC is a type of 5G connection that is designed for applications that require very low latency and high reliability. This makes URLLC ideal for applications such as self-driving cars and remote surgery.
  • Massive machine-type communication (mMTC): mMTC is a type of 5G connection that is designed for applications that need to connect a large number of devices. This makes mMTC ideal for applications such as smart city infrastructure and industrial IoT.
  • Enhanced mobile broadband (eMBB): eMBB is a type of 5G connection that is designed for applications that need high-speed data transfer. This makes eMBB ideal for applications such as streaming video and gaming.

Overall, 5G is a significant improvement over 4G in terms of speed, latency, capacity, and features. As 5G networks continue to roll out, we can expect to see even more innovative applications and services that take advantage of this new technology.

Here is a table that summarizes the key differences between 4G and 5G:

Feature

4G

5G

Peak download speed

1 Gbps

10 Gbps

Peak upload speed

100 Mbps

20 Gbps

Latency

50 ms

1 ms

Capacity

100,000 devices per square kilometer

1 million devices per square kilometer

Features

VoLTE, HD Voice, LTE Advanced

URLLC, mMTC, eMBB


Sunday, August 20, 2023

Differences - Comparisions Tech

Differences between Git and GitHub:

FeatureGitGitHub
What is it?A version control systemA web-based hosting service for Git repositories
Who owns it?Open source softwareMicrosoft
CostFree to useFree for individuals, paid plans for teams and organizations
FeaturesTracks changes to code over time, allows you to revert to previous versions, compare different versions, and collaborate with othersProvides a place to store your Git repositories, as well as a number of features that make it easy to collaborate with others, such as issue tracking, pull requests, and wikis

Friday, August 18, 2023

Comparing Programming languages- Latest

 

Language

Popularity

Use cases

Pros

Cons

Python

Most popular

Data science, machine learning, web development, automation

Simple, readable, versatile

Not as fast as some other languages

JavaScript

Second most popular

Web development, mobile app development, server-side applications

Interactive, lightweight

Can be difficult to debug

Java

Third most popular

Enterprise software development, mobile app development, game development

Portable, secure

Can be verbose

C++

Fourth most popular

High-performance applications, games, operating systems

Fast, efficient

Complex, difficult to learn

Go

Fifth most popular

Cloud-native applications, microservices

Simple, concise

Not as mature as some other languages

Rust

Sixth most popular

High-performance applications, operating systems, embedded systems

Safe, fast

Not as widely used as some other languages

Sunday, August 6, 2023

Hash table Binary search tree stack java program

 import java.util.Hashtable;

public class javaHashtable { public static void main(String[] args) { //1. Create Hashtable Hashtable<Integer, String> myHT = new Hashtable<>(); //2. Add mappings to hashtable myHT.put(1, "Ahmad"); myHT.put(2, "Bilal" ); myHT.put(3, "Omer"); //3. Remove mapping for key 3 myHT.remove(3); //3 is deleted //4. Add mapping: 2, Abdullah myHT.put(2, "Abdullah" ); System.out.println(myHT); } } Output: {2=Abdullah, 1=Ahmad}

===========================================

Binary search tree and performs in-order, pre-order, and post-order traversals on the tree. import java.util.Scanner; class Node { int data; Node left, right; Node(int k) { data = k; left = right = null; } } class BST { Node root; BST() { root = null; } void insert(int key) { root = insertRec(root, key); } Node insertRec(Node root, int key) { if (root == null) { // insert in empty tree return new Node(key); } if (key < root.data) { // recur down the left subtree root.left = insertRec(root.left, key); } else { // recur down the right subtree root.right = insertRec(root.right, key); } return root; } void inorder() { inorderRec(root); } void inorderRec(Node root) { if (root != null) { // inorder traversal inorderRec(root.left); System.out.println(root.data); inorderRec(root.right); } } void preorder() { preorderRec(root); } void preorderRec(Node root) { if (root != null) { // preorder traversal System.out.println(root.data); preorderRec(root.left); preorderRec(root.right); } } void postorder() { postorderRec(root); } void postorderRec(Node root) { if (root != null) { // postorder traversal postorderRec(root.left); postorderRec(root.right); System.out.println(root.data); } } public static void main(String[] args) { BST bst = new BST(); bst.insert(50); bst.insert(30); bst.insert(70); bst.insert(20); bst.insert(40); bst.insert(60); bst.insert(80); System.out.println("In-order traversal: "); bst.inorder(); System.out.println("Pre-order traversal: "); bst.preorder(); System.out.println("Post-order traversal: "); bst.postorder(); } }

=========================
//stack push pop import java.util.LinkedList; public class Stack { private LinkedList<String> list = new LinkedList<>(); // This method should push an element onto the stack. public void push(String Planets) { // Add the element to the front of the list. list.addFirst(Planets); } // This method should pops the top element off the stack. public String pop() { // Remove the element from the front of the list. return list.removeFirst(); } // This method should prints the elements in the stack. public void print() { // Iterate through the list and print each element. for (String Planets : list) { System.out.println(Planets); } } // This is the main method of the program. public static void main(String[] args) { // Create a new stack. Stack stack = new Stack(); // Push three Planetss onto the stack Apple, Banana, orange stack.push("Earth"); stack.push("Jupiter"); stack.push("Mars"); // Print the stack. stack.print(); // Pop the top element off the stack. System.out.println("The top element is: " + stack.pop()); // Print the stack again. stack.print(); } }

Tuesday, August 1, 2023

Java Programs example

 Java Programs example Priority Queue 


// Priority Queue  

import java.util.Scanner;

class Node {

public int requestID, priority;

public Node next; 

public Node(int id, int p) {

requestID=id; priority=p; 

}

}

//////////////////////////////////////////////

class mySLL_Queue {

protected Node head, tail;

public mySLL_Queue() { head = tail = null; }

public void enqueue(int el, int p) { // addToTail 

Node newNode = new Node(el, p);

newNode.next = null; 

if (head == null) // empty

head = tail = newNode; 

else {

tail.next = newNode;

tail = newNode;

}

}


public int dequeue() { // deleteFromHead

if(head == null) // empty

return -1;

int el = head.requestID;

if (head == tail) // if only one node on the list;

head = tail = null;

else {

int p =10; // remove a node with highest priority

while( (el=delete(p)) == -1)

 p--;

}

return el;

}

public void printAll() {

for (Node tmp = head; tmp != null; tmp = tmp.next)

System.out.println(tmp.requestID + "(" + tmp.priority + ")" );

}

public int delete(int p) { // delete target node with el;

Node prev = head, tmp = head.next;

while ( tmp != null && tmp.priority != p) {

prev = prev.next;

tmp = tmp.next;

}

if (tmp != null) { // if el was found;

prev.next = tmp.next;

if (tmp == tail) // if el is in last node;

tail = prev;

}

else 

return -1;

return tmp.requestID;

} ////////////////////////////////////

///////////////////////////////////////////////

public class Queue_Using_SinglyLinkedList {

public static void main(String[] args) {

mySLL_Queue sllQueue = new mySLL_Queue();

 int cust=1, opt, pri;

 Scanner sc = new Scanner(System.in);

 while (true){

 System.out.println("Priority Queue\n 1. Add a customer\n 2. Remove a customer\n3. Show the queue\n4. Exit \n Your choice? ");

 opt = sc.nextInt();

 

 if(opt==1){

 System.out.println("Enter priority? ");

 pri = sc.nextInt();

 System.out.print("Added Customer # ");

 sllQueue.enqueue(cust++, pri);

 }

 else if(opt==2){

 System.out.println("Removed customer # " + sllQueue.dequeue());

 }

 else if(opt==3){

 System.out.print("Queue = " ); 

 sllQueue.printAll();

 }

 else if(opt==4){

 return; 

 }

 else

 System.out.println("Wrong option selected...");

 }

}

}



===

// Evaluating Postfix Expression

import java.util.*;

import java.util.Scanner;

public class Postfix {

 public static void main(String[] args) {

 System.out.println("Evaluating Postfix Expression\n");

 Scanner sc = new Scanner(System.in);

 System.out.println("Input an expression:");

 String exp = sc.nextLine();

 System.out.println(postfixEvaluate(exp)); 

 }

 

 public static Double postfixEvaluate(String exp) {

Stack<Double> s = new Stack<Double> ();

Scanner tokens = new Scanner(exp);

while (tokens.hasNext()) {

if (tokens.hasNextDouble()) {

s.push(tokens.nextDouble());

}

else {

Double num2 = s.pop();

Double num1 = s.pop();

String op = tokens.next();

if (op.equals("+")) {

s.push(num1 + num2);

else if (op.equals("-")) {

s.push(num1 - num2);

else if (op.equals("*")) {

s.push(num1 * num2);


else if (op.equals("/")) {

s.push(num1 / num2);

}

else

 System.out.println("Error in input...");

}

}

return s.pop();

 } 

}


=============


//bst  Modify BST_Recursive.java of Lab-10:Exercise#2 to write a complete program to 

//implement a spare-parts database with itemNo, price and description. 



import java.util.Scanner;

class BSTNode {

 int itemNum;

 double Price;

 String Discription;

 BSTNode left, right;

 public BSTNode(int itemNum, double Price, String Discription) {

 this.itemNum = itemNum;

 this.Price = Price;

 this.Discription = Discription;

 left = right = null;

 }

}

class BinaryTree {

 BSTNode root;

 BinaryTree() { root = null; }

 boolean searchByItemNum(int itemNum){ return searchRecursion(root, itemNum) != null; }

 public BSTNode searchRecursion(BSTNode root, int num) {

 if (root==null || root.itemNum ==num)

 return root;

 if (root.itemNum > num)

 return searchRecursion(root.left, num);

 return searchRecursion (root.right, num);

}

 void deleteKey(int num) {

 root = deleteRec(root, num);

 }

 BSTNode deleteRec(BSTNode root, int num) {

 if (root == null) return root;

 if (num < root.itemNum)

 root.left = deleteRec(root.left, num);

 else if (num > root.itemNum)

 root.right = deleteRec(root.right, num);

 else {

 if (root.left == null)

 return root.right;

 else if (root.right == null)

 return root.left;

 root.itemNum = minValue(root.right);

 root.right = deleteRec(root.right, root.itemNum);

 }

 return root;

 }

 int minValue(BSTNode root) {

 int minv = root.itemNum;

 while (root.left != null) {

 minv = root.left.itemNum;

 root = root.left;

 }

 return minv;

 }

 void insert(int num,double price,String dis) {

 root = insertRec(root, num,price,dis);

 }

 BSTNode insertRec(BSTNode root, int Num,double price,String disc) {

 if (root == null) {

 root = new BSTNode(Num,price,disc);

 return root;

 }

 if (Num < root.itemNum)

 root.left = insertRec(root.left,Num,price,disc);

 else if (Num > root.itemNum)

 root.right = insertRec(root.right,Num,price,disc);

 return root;

 }

 void inorder() {

 if(root == null)

 System.out.println("== DATABASE IS EMPTY ! ==");

 else

 inorderRec(root);

 }

 void inorderRec(BSTNode root) {

 if (root != null) {

 inorderRec(root.left);

 System.out.print("\n================================\nItem Num.: "+root.itemNum + "\nPrice : 

"+root.Price+"\nDescription : "+root.Discription+"\n================================\n");

 inorderRec(root.right);

 }

 }

 void Run() {

 Scanner sc = new Scanner(System.in);

 int n;

 System.out.print("\n1.insert. \n2.Search. \n3.Delete. \n4.Show all. \n5.Exit.");

 System.out.print("\n\nYour option : ");

 n = sc.nextInt();

 switch (n) {


case 1:

 System.out.print("\nEnter Item Number: ");

 int item;

 item = sc.nextInt();

 System.out.print("Enter Price: ");

 double price;

 price = sc.nextDouble();

 System.out.print("Enter Discription: ");

 String Discription;

 Discription = sc.next();

 insert(item, price, Discription);

 System.out.println("\n<< Item " + item + " added >>\n");

 Run();

 break;

 case 2:

 System.out.print("\nEnter item Num. : ");

 int nu;

 nu = sc.nextInt();

 if (searchByItemNum(nu)) {

 System.out.println("\n << Found >> ");

 System.out.print("\n================================\nItem No.: " + root.itemNum + "\nPrice : " + root.Price + 

"\nDescription : " + root.Discription + "\n================================\n");

 } else {

 System.out.println(" ** Not Found ** ");

 }

 Run();

 break;

 case 3:

 System.out.println("\nEnter item Num. : ");

 int num;

 num = sc.nextInt();

 deleteKey(num);

 Run();

 break;

 case 4:

 inorder();

 Run();

 break;

 case 5:

 return;

 default:

 System.out.println("ENTER NUMBER FROM '1 TO 5'");

 Run();

 break;

 }

 }

}

public class hw5a {

 public static void main(String[] args) {

 System.out.println("<< Spare-parts Database >>");

 BinaryTree bst = new BinaryTree();

 bst.Run();

 }

}


================

//Dijkstra’s algorithm for shortest path u

import java.util.*;

// Data structure to store graph edges

class Edge {

 int source, dest, weight;

 public Edge(int source, int dest, int weight) {

 this.source = source;

 this.dest = dest;

 this.weight = weight;

 }

}

// Data structure to store heap nodes

class Node {

 int vertex, weight;

 public Node(int vertex, int weight) {

 this.vertex = vertex;

 this.weight = weight;

 }

}

// class to represent a graph object

class Graph {

 // A List of Lists to represent an adjacency list

 List<List<Edge>> adjList = null;

 // Constructor

 Graph(List<Edge> edges, int N) {

 adjList = new ArrayList<>(N);

 for (int i = 0; i < N; i++) {

 adjList.add(i, new ArrayList<>());

 }

 // add edges to the undirected graph

 for (Edge edge: edges) {

 adjList.get(edge.source).add(edge);

 }

 }

}

public class Dijkstra_aryLists {

 private static void getRoute(int prev[], int i, List<Integer> route) {

 if (i >= 0) {

 getRoute(prev, prev[i], route);

 route.add(i);

 }

 }

 // Run Dijkstra's algorithm on given graph

 public static void shortestPath(Graph graph, int source, int N) {

 // create min heap and push source node having distance 0

 PriorityQueue<Node> minHeap;

 minHeap = new PriorityQueue<>(Comparator.comparingInt(node -> node.weight));

 minHeap.add(new Node(source, 0));

 // set infinite distance from source to v initially

 List<Integer> dist = new ArrayList<>(Collections.nCopies(N, Integer.MAX_VALUE));

 // distance from source to itself is zero

 dist.set(source, 0);

 // boolean array to track vertices for which minimum

 // cost is already found

 boolean[] done = new boolean[N];

 done[source] = true;

 // stores predecessor of a vertex (to print path)

 int prev[] = new int[N];

prev[source] = -1;

 List<Integer> route = new ArrayList<>();

 // run till minHeap is not empty

 while (!minHeap.isEmpty()) {

 // Remove and return best vertex

 Node node = minHeap.poll();

 // get vertex number

 int u = node.vertex;

 // do for each neighbor v of u

 for (Edge edge: graph.adjList.get(u))

 {

 int v = edge.dest;

 int weight = edge.weight;

 // Relaxation step

 if (!done[v] && (dist.get(u) + weight) < dist.get(v))

 {

 dist.set(v, dist.get(u) + weight);

 prev[v] = u;

 minHeap.add(new Node(v, dist.get(v)));

 }

 }

 // marked vertex u as done so it will not get picked up again

 done[u] = true;

 }

 for (int i = 1; i < N; ++i) {

 if (i != source && dist.get(i) != Integer.MAX_VALUE) {

 getRoute(prev, i, route);

 System.out.printf("Path (%d -> %d): Minimum Cost = %d and Route is %s\n",

 source, i, dist.get(i), route);

 route.clear();

 }

 }

 }

 public static void main(String[] args) {

 Scanner sc=new Scanner(System.in);

 // initialize edges as per above diagram

 // (u, v, w) triplet represent undirected edge from

 // vertex u to vertex v having weight w

 // Set number of vertices in the graph

 System.out.println("Enter The number of edges");

 int N=sc.nextInt();

 List<Edge> edges = new ArrayList<Edge>();

 for(int i=0;i<N;i++) {

 System.out.println("Enter the values for edge " + i);

 System.out.println("Enter The values of U");

 int u=sc.nextInt();

 System.out.println("Enter The values of V");

 int v=sc.nextInt();

 System.out.println("Enter The values of W");

 int w=sc.nextInt();

 edges.add(new Edge(u, v, w));

 }

 // construct graph

 Graph graph = new Graph(edges, N);

 int source = 0;

 shortestPath(graph, source, N);

 }

}


================


//Hashing. 

// Provide an option menu: 1) Insert, 2) Find, 3) Delete, 4) Show table, 5) Exit. 

//Input user option and data to perform the required operation.

import java.util.Scanner;

public class Hashtable_Using_Java_Class {

 public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

 //1. Create Hashtable

 Hashtable<Integer, String> ht = new Hashtable<>();

 char ch;

while(true){

System.out.println("\nHash Table Operations\n");

System.out.println("1. Insert ");

System.out.println("2. Find");

System.out.println("3. Delete"); 

System.out.println("4. Show");

System.out.println("5. Exit");

int choice = scan.nextInt();

switch (choice) {

case 1 : 

System.out.println("Enter key and value");

ht.put(scan.nextInt(), scan.next() ); 

break; 

case 2 : 

System.out.println("Enter key");

System.out.println("Value = "+ ht.get( scan.nextInt() )); 

break; 

case 3 : 

System.out.println("Enter key");

ht.remove( scan.nextInt() ); 

break; 

case 4 : 

System.out.println("Hash Table = \n" + ht);

break;

case 5 : 

System.out.println("Bye... " );

break; 

default : 

System.out.println("Wrong option... \n ");

break; 

}

 }

}


Data Structures in Pictures



Data Structures in pictures












 

Cybersecurity Sales

  1. How do you sell cybersecurity to a non-technical C-suite executive? Answer: "I don't sell technology; I sell risk management....