This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | |
pageEncoding="ISO-8859-1"%> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="ISO-8859-1"> | |
<title>Create a new user</title> | |
</head> | |
<body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Color; | |
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
import javax.swing.*; | |
public class Appv1 extends Conn implements ActionListener{ | |
// all elements must be static for results to display correctly | |
static JFrame f,j2; | |
static JTextField t1, t2, t3, t4, t5, t6, t7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void sort(int arr[]) | |
{ | |
// to sort the elements | |
int n = arr.length; | |
// build max heap | |
for(int i = n/2 - 1 ;i>=0; i--) | |
{ | |
// i=n/2-1 as it will give us the left and right child nodes at the first level of the heap | |
heapify(arr,n,i); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HeapSort { | |
public static void main(String[] args) { | |
int arr[] = {3,37,29,5,7,4,3,2,5,6,29,7,9,3,8,21,15,16,9,55,8,10,101,57,9,12}; | |
System.out.println("Before heapsort the array is: "); | |
printlist(arr); | |
sort(arr); | |
System.out.println("\nAfter heap sort the array is: "); | |
printlist(arr); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void heapify(int arr[], int n, int i) { | |
// Find largest among root, left child and right child | |
int largest = i; | |
int left = 2 * i + 1; | |
int right = 2 * i + 2; | |
if (left < n && arr[left] > arr[largest]) | |
largest = left; | |
if (right < n && arr[right] > arr[largest]) |