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












 

virtual representations of physical objects or systems.

Digital Twins - Virtual Replicas of Cities, Factories, or Human Organs for Simulations How virtual copies are revolutionizing the phys...