Computer Science  >  Research Paper  >  University of Houston - CS 6320ExternalSort.java (All)

University of Houston - CS 6320ExternalSort.java

Document Content and Description Below

import java.util.Scanner; import java.io.PrintWriter; import java.nio.file.Path; import java.nio.file.Paths; public class ExternalSort { public static String sort(String s){ String[] vals = s.sp ... lit(" "); int array[] = new int[vals.length]; for(int k = 0; k < vals.length; k++){ array[k] = Integer.parseInt(vals[k]); } for(int j = 1; j < vals.length; j++){ int key = array[j]; int x = j - 1; while(x >= 0 && array[x] > key){ array[x + 1] = array[x]; x = x - 1; } array[x + 1] = key; } String text = ""; for(int k = 0; k < vals.length; k++){ text += array[k] + " "; } return text; } public static void printPath(Path p){ try(Scanner sc = new Scanner(p);){ while(sc.hasNextInt()){ System.out.print(sc.nextInt() + " "); } System.out.println(); } catch(Exception e){ System.out.println(e); } } public static Path extsort(Path t1, int runsize){ Path t2 = Paths.get("C:\\UTD\\DataStrucs\\Project4\\t2.txt"); Path t3 = Paths.get("C:\\UTD\\DataStrucs\\Project4\\t3.txt"); Path t4 = Paths.get("C:\\UTD\\DataStrucs\\Project4\\t4.txt"); try(Scanner sc = new Scanner(t1);){ int total = 0; PrintWriter print1 = new PrintWriter(t3.toString()); PrintWriter print2 = new PrintWriter(t4.toString()); while(sc.hasNextInt()){ int count = 0; String toPrint = ""; while(sc.hasNextInt() && count < runsize){ toPrint += sc.nextInt() + " "; count++; total++; } [Show More]

Last updated: 3 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of University of Houston - CS 6320ExternalSort.java document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$5.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

Can't find what you want? Try our AI powered Search

84
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 10, 2021

Number of pages

4

Written in

All

Seller


Profile illustration for Muchiri
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Apr 10, 2021

Downloads

 0

Views

 84

Document Keyword Tags

Recommended For You

Get more on Research Paper »

$5.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·