Arman Aşçı's Personal Blog Page

HOME   PROJECTS   CONTACT



Java Simple Server-Client Text Based Chat Example

Download source and byte code

The client–server model is a distributed application structure in computing that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. Often clients and servers communicate over a computer network on separate hardware, but both client and server may reside in the same system. A server is a host that is running one or more server programs which share their resources with clients. A client does not share any of its resources, but requests a server’s content or service function. Clients therefore initiate communication sessions with servers which await incoming request

Read more…

Written by armanasci

May 16th, 2013 at 8:28 pm

Posted in Java,Programming

Tagged with , , , ,

Java Linked List Data Structure Example

Download source and byte code

When we need to allocate memory space dynamically on run time and we don’t know the data size exactly, we should prefere linked list.
In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of a datum and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
Singly-linked-list.svg On the other hand, simple linked lists by themselves do not allow random access to the data, or any form of efficient indexing. Thus, many basic operations — such as obtaining the last node of the list (assuming that the last node is not maintained as separate node reference in the list structure), or finding a node that contains a given datum, or locating the place where a new node should be inserted — may require scanning most or all of the list elements.

Read more…

Written by armanasci

May 16th, 2013 at 6:21 pm

Harlem Shake at Cyprus International University

Written by armanasci

April 28th, 2013 at 2:20 pm

Posted in General

Tagged with ,

Cpu Time Scheduler/Sharing Algorithms C++ Simulator

Download linux binary and source code


Screen Shots of the program

Process Name
Process Burst Time
Process Arrival Time
Process Priority
P1
4
0
3
P2
3
1
2
P3
2
2
1
P4
4
2
2
P5
3
3
1

Processes

Input file

Context Switching : A context switch is the computing process of storing and restoring the state (context) of a Process so that execution can be resumed from the same point at a later time. This enables multiple processes to share a single CPU. The context switch is an essential feature of a multitasking operating system. Context switches are usually computationally intensive and much of the design of operating systems is to optimize the use of context switches. A context switch can mean a register context switch, a task context switch, a thread context switch, or a process context switch. What constitutes the context is determined by the processor and the operating system.

1-) First-Come, First-Served Scheduling

By far the simplest CPU-scheduling algorithm is the first-come, first-served (FCFS) scheduling algorithm. With this algorithm, processes are assigned the CPU in the order they request it. Basically, there is a single queue of ready processes. Relative importance of jobs measured only by arrival time (poor choice). The implementation of the FCFS policy is easily managed with a FIFO queue. When a process enters the ready queue, its PCB is linked onto the tail of the queue. The average waiting time under the FCFS policy, however, is often quite long. Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in milliseconds.

FCFS Waiting times and average waiting time calculation

P1 = 4-0-4 = 0ms
P2 = 7-1-3 = 3ms
P3 = 9-2-2 = 5ms
P4 = 13-2-4 = 7ms
P5 = 16-3-3 = 10ms
Average = (0+3+5+7+10)/5 = 5ms

Read more…

Written by armanasci

February 6th, 2013 at 9:37 pm

Greedy Search Algorithm (Greedy Routing)

Download bytecode and source code

1.1 What is the greedy search algorithm ?

Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen according to a specified rule. Judea Pearl described best-first search as estimating the promise of node n by a "heuristic evaluation function which, in general, may depend on the description of n, the description of the goal, the information gathered by the search up to that point, and most important, on any extra knowledge about the problem domain. Some authors have used "best-first search" to refer specifically to a search with a heuristic that attempts to predict how close the end of a path is to a solution, so that paths which are judged to be closer to a solution are extended first. This specific type of search is called greedy best-first search [1] A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum. In many problems, a greedy strategy does not in general produce an optimal solution, but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a global optimal solution in a reasonable time. For example, a greedy strategy for the traveling salesman problem (which is of a high computational complexity) is the following heuristic: "At each stage visit an unvisited city nearest to the current city". This heuristic need not find a best solution but terminates in a reasonable number of steps; finding an optimal solution typically requires unreasonably many steps. In mathematical optimization, greedy algorithms solve combinatorial problems having the properties of matroids.[2]

1.2 Properties of greedy search algorithm

Time Complexity: O(bm), but a good heuristic can give dramatic improvement
Space Complexity: O(bm), keeps all nodes in memory
Greedy Search uses : f(n) = h(n)
Optimality: Not optimal, it can follow initially good but misleading paths (same as dfs. However, a good heuristic can reduce time and memory costs substantially

1.3 Understanding the algorithm

Image1 Bulgaria Map

Read more…

Written by armanasci

February 6th, 2013 at 3:46 pm

Java Abstract Class Example

Download java source and cross-platform executable

What is abstract class ?

In programming languages, an abstract type is a type in a nominative type system which cannot be instantiated. (However, it may have concrete subtypes that do have instances.) An abstract type may have no implementation, or an incomplete implementation. It may include abstract methods or abstract properties that are shared by its subtypes.
In many object oriented programming languages, abstract types are known as abstract base classes. In some languages, abstract types with no implementation are known as interfaces. Other names for language features that are (or may be) used to implement abstract types include traits, mixins, flavors, or roles. A type that is not abstract is called a concrete type (or concrete class).

Read more…

Written by armanasci

February 5th, 2013 at 4:42 pm

Posted in Java,Programming

Tagged with , , , ,

Java UML Excercise

Download java source and cross-platform executable

What is uml ?

Unified Modeling Language (UML) is a standardized general-purpose modeling language in the field of object-oriented software engineering. The Unified Modeling Language includes a set of graphic notation techniques to create visual models of object-oriented software-intensive systems. The Unified Modeling Language was developed by Grady Booch, Ivar Jacobson and Jim Rumbaugh at Rational Software in the 1990s. It was adopted by the Object Management Group (OMG) in 1997, and has been managed by this organisation ever since. In 2000 the Unified Modeling Language was accepted by the International Organization for Standardization (ISO) as industry standard for modeling software-intensive systems. Unified Modeling Language is used to specify, visualize, modify, construct and document the artifacts of an object-oriented software-intensive system under development. The metamodeling architecture of Unified Modeling Language (UML) is defined in the Meta-Object Facility (MOF).

Read more…

Written by armanasci

February 5th, 2013 at 4:29 pm

Posted in Java,Programming

Tagged with , , , ,