Posts

CS3550 Final Exam

1. Identify True or False for the following statements: (10*1 = 10) (a) A TCP header has source and destination port address. ___ (b) OSI model has 5 layers. ___ (c) In a TCP/IP model, an application can communicate with the underneath transport layer through a port number. ____ (d) PDU header has the control information. ____ (e) UDP is an example of TCP protocol. _____ (f) HTTP is an example of TCP protocol. _____ (g) UDP provides a reliable connection for transferring data between applications. ___ (h) A TCP header is minimum 160 bits. _____ (i) TCP header does not contain sequence and acknowledge number. ____ (j) A UDP header has source and destination IP address. ____ 2. For TCP protocol, show the sequence of packet exchange for the following: (a) 3-way handshake, and (b) Connection closing or teardown. (3+3=6) Ans: 3. Briefly discuss three characteristics of TCP that ensure reliable communication. (2*3= 6) Ans: 4. Consider the following ...

Caesar Cipher in Java

Credit goes to Musa Mohammed for his help. import java.util.Scanner; public class CaesarCipher { public static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; public static String encrypt(String plain_Text,int shiftKey) { plain_Text = plain_Text.toLowerCase(); String cipherText=""; for(int i=0;i<plain_Text.length();) { if(plain_Text.charAt(i) == ' ') { cipherText += plain_Text.charAt(i); i++; } else { int charPosition = ALPHABET.indexOf(plain_Text.charAt(i)); int keyVal = (shiftKey+charPosition)%26; char replaceVal = ALPHABET.charAt(keyVal); cipherText += replaceVal; i++; } } return cipherText; } public static String decrypt(String cipherText, int shiftKey) { cipherText = cipherT...

Timer/Count Down in standard C

#include <stdio.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <setjmp.h> static void sig_alarm (int signo); void err_sys (const char* message); static jmp_buf alarm_jmp; int main (int argc, char* argv[]) { int time_left = 10; if (signal (SIGALRM, sig_alarm) == SIG_ERR) err_sys ("alarm signal error"); alarm (1); if (sigsetjmp (alarm_jmp, 1) != 0) { time_left--; if (time_left == 0) { printf ("BOOM\n"); exit(0); } else { printf ("%d\n", time_left); alarm (1); } } while (1); exit(0); } static void sig_alarm (int signo) { siglongjmp (alarm_jmp, 1); } void err_sys (const char* message) { printf ("%s\n", message); exit (0); }

CS3401 HW 7

package trees; /** Course: CS 3401  * Section: 01  * Name: Dalibor Labudovic  * Professor: Prof. Shaw  * Assignment #: Homework #7  */  import java.math.BigDecimal; import java.util.*; //******************************************************************** // Evaluates a given expression by first converting it to a // Postfix Stack and then to an Expression Tree and then // evaluating the Expression Tree //********************************************************************  public class EvaluateExpressionTree {  public static void main(String[] args) {  Scanner input = new Scanner(System.in);  System.out.println("Enter an equation in infix notation: " + "[Ex: 10+6/3 ]");  String expression = input.nextLine();  input.close();  try {  System.out.println("Result = " + evaluateExpressionTree(expression).stripTrailingZeros().toPlainString());  }  catch (Exception ex) {  System.out.println...

CS3401 Homework Assignment 8

Image
Homework Assignment #8 Exercise #1 Modify the DisplayBinaryTree.java class given out in Sample Code #8, to add three new buttons: "Show Inorder", "Show Preorder", and "Show Postorder". Each of these buttons when pressed must pop up a JOptionPane message dialog box that shows the values in the tree listed in the proper order for the ordering controlled by that button. For instance, if the "Show Inorder" button is pressed for the following tree: Then a pop up dialog will show something like: And if the user had pressed the "Show Preorder" button, a pop up dialog will show something like the following: And if the user had pressed the "Show Postorder" button, a pop up dialog will show something like the following: You will need the following three classes in your class hierarchy in order to get your program working (they are the same ones from the last assignment, and you should not change them at all): ...

CS3401 Quiz 6

Image
Question 1 5 / 5 points Which of the following are the three  major categories  of Java  Collections ? lists, sets, maps hash tables, hash maps, hash sets arraylists, linkedlists, vectors trees, lists, maps Question 2 5 / 5 points A collection that does not impose a positional order on its elements, and does not allow duplicates is called which of the following? A hashmap A linkedlist A vector A set Question 3 5 / 5 points A collection whose elements are pairs of  keys  and  values  is called which of the following? An iterator A map A binary tree A heap Question 4 0 / 5 points Ideally, the  hash codes  of two objects  should be  which of the following: The should be equal when the objects belong to the same class, and different when the objects belong to different classes They should be equal when the objects are of the same type, and ...

KSU CS Program Books in PDF

Books Disclaimer: These are not owned by me, i dont not own this material. Use with copy right caution.