Notes, summaries, assignments, exams, and exercises for Computer science for Primary education

Prolog Implementation of the Traveling Salesperson Problem: Exact and Heuristic Solvers

Computer scienceUpdated on 4.75 KB

This document presents two distinct approaches to solving the Traveling Salesperson Problem (TSP) using Prolog: an exact, brute-force method and a heuristic-based Nearest Neighbor algorithm. Both implementations are demonstrated with code and sample queries.

Exact Solver: Brute-Force TSP Algorithm

This section details a Prolog program that finds the optimal (shortest) path for the Traveling Salesperson Problem by generating and evaluating all possible tours. This method guarantees the optimal solution but can be computationally intensive for larger sets of cities.

Defining City Distances in Prolog

The distances between cities are defined using dist/3 facts. The predicate is made symmetric to ensure that dist(X,Y,D) implies dist(Y,X,D).

dist(a,b,
...
Continue reading "Prolog Implementation of the Traveling Salesperson Problem: Exact and Heuristic Solvers" »

Step-by-Step Installation of OmniOS with Napp-IT

Computer scienceUpdated on 3.94 KB

Manual Installation:
Current State (Tests are Conducted in ESXi5):


1. Download OmniOS (Bloody or Stable)
2a. Option: Run on ESXi, create a new VM (Solaris 10-64) with e1000 or install on hardware (15 GB disk minimum)

2b. Run on Hardware:
You can install Omni + Napp-IT onto SATA or fast USB sticks >=16 GB (absolute minimum=8 GB when needed).
If you use USB, the best are external USB3 enclosures with a SATA SSD >=16 GB inside.
(Prefer USB3; they are mostly even faster on USB2)

3. Install with defaults from CD or USB install media, login as root (no password)

4. Setup Network. Network is set to (by default): network/physical:default,
so login as root (no password)

4.1 Create Interface
- List available interfaces and use link name, e.g., e1000g0:
dladm...

Continue reading "Step-by-Step Installation of OmniOS with Napp-IT" »

Software Testing and Debugging

Computer science4.52 KB

SOFTWARE TESTING

Testing can only show the presence of errors, not their absence. The goal of testing is confidence.

  • Validation: Are we building the right product? What does the customer need?
  • Verification: Are we building the product right? Functional/Non-Functional requirements.

SOFTWARE INSPECTION VS. SOFTWARE TESTING

While inspection will go through the code without running the program, testing will run the program and look at the results. Incomplete programs can only be inspected, not tested. Inspections can control aspects of good software (maintainability…), not just the results.

TEST CASE:

  • Requirements
  • Data/Input
  • Actions
  • Expected Results

TEST CASE PRINCIPLES:

  • A test tries to find flaws in a program.
  • A good test case will show a possible defect
...
Continue reading "Software Testing and Debugging" »

Key Concepts in Information Systems and Technology

Computer science5.24 KB

Expert systems

have four major components. Which of the following is not one of the four?

  • Interference motor

Major categories of E-commerce

include all of the following except which one?

  • Business to department (B2D)

Computing environment

that is always present and is capable perceive the surroundings and offer recommendations based on individual need and requirement is known as:

  • Contextual computing

AI application

includes Bots, Virtual agents, and Intelligent virtual agents. Which of the following best describes this AI technology?

  • Intelligent agents

Application used in all the functions of a business

which supports decision making throughout the organization is known as___

  • Enterprise system

Four phases of the decision-making process

in a typical organization...

Continue reading "Key Concepts in Information Systems and Technology" »

Java AWT Architecture: Components, Events & Listeners

Computer science11.3 KB

Java AWT Architecture: Components and Events

The Abstract Window Toolkit (AWT) is Java's original platform-dependent windowing, graphics, and user interface (UI) toolkit.

AWT Class Hierarchy

🖼️ The core of the AWT is structured around a few key classes, all of which inherit from the Object class.

1. Component Class

The Component class is the root of all AWT UI elements. A Component is an object with a graphical representation that can be displayed on the screen and can interact with the user. Examples of components include buttons, text fields, and scrollbars.

  • Key capabilities:
    • Defining visual appearance and behavior
    • Handling events (user input)
    • Drawing and painting

2. Container Class

A Container is a special type of component that can hold and organize...

Continue reading "Java AWT Architecture: Components, Events & Listeners" »

Computer Memory Systems and I/O Device Management

Computer science12.61 KB

🧠 Computer Memory Systems

Computer memory is essential for storing data and instructions. It is measured and organized using specific terminologies and a hierarchical structure.

1. Fundamental Memory Concepts

A. Basic Units of Data Storage

The smallest addressable units of data in a computer are based on the binary system:

UnitSizeDescription
Bit (Binary Digit)1The smallest unit of data, represented as either a 0 or a 1.
Nibble4 bitsHalf of a byte; often corresponds to a single hexadecimal digit.
Byte8 bitsThe fundamental unit of data storage; typically represents a single character (e.g., 'A', '7', '$').
WordVaries (16, 32, 64 bits)The natural unit of data used by a specific CPU design (its register size and bus width).

B. Storage Locations and Addresses

  • Storage
...
Continue reading "Computer Memory Systems and I/O Device Management" »

Understanding SEO: A Comprehensive Guide to Search Engine Optimization

Computer science4.24 KB

Understanding Search Engine Optimization (SEO)

Crawling and Indexing

Web crawlers, also known as bots, robots, or spiders, are software programs designed to follow links, gather information, and send it back to search engines for indexing. This process allows search engines to understand the content and structure of websites.

Evolution of Google Search Algorithms

Over the years, Google has implemented various algorithm updates to improve search results and combat spam. Some notable updates include:

  • Google Dance (2002): Click-through rates started influencing search rankings.
  • Austin (2004): Targeted websites with keyword stuffing.
  • Google Suggest (2008) & Google Instant (2010): Introduced predictive search based on search history.
  • Hummingbird (2013)
...
Continue reading "Understanding SEO: A Comprehensive Guide to Search Engine Optimization" »

Understanding Cache Memory and CPU Hazards

Computer science2.83 KB

1. General Questions (35%)

1.1. (5%) What is the difference between a write-back cache and a write-through cache?

Write-back cache: A store only writes data to the cache and marks the corresponding line as dirty. The modified line is written to the lower level of the memory hierarchy only when it is evicted.

Write-through cache: Data is written to the caches and the memory every time a store is executed.

1.2. (15%) Name the 3 Cs in cache misses and provide a brief explanation for each C.

Compulsory miss: A cache miss caused by the first access, a cold start effect.

Capacity miss: A cache miss due to the capacity limitation. Even with full associativity, it cannot accommodate all the working sets of an application.

Conflict miss: A cache miss that...

Continue reading "Understanding Cache Memory and CPU Hazards" »

Python Syntax, Indentation, Comments, Variables, Data Types, Numbers, Casting, and Strings

Computer science5.67 KB

Python Syntax

As we learned in the previous page, Python syntax can be executed by writing directly in the Command Line:

>>> print("Hello, World!")
Hello, World!

Python Indentation

Indentation refers to the spaces at the beginning of a code line.

Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.

Python uses indentation to indicate a block of code.

if5 > 2:
    print("Five is greater than two!")

Python will give you an error if you skip the indentation:

if5 > 2:
print("Five is greater than two!")

Python Comments

Comments can be used to explain Python code.

Comments can be used to make the code more readable.

Comments can be used to prevent execution when testing...

Continue reading "Python Syntax, Indentation, Comments, Variables, Data Types, Numbers, Casting, and Strings" »

Understanding the C Programming Language: History and Structure

Computer science12.78 KB

That's a great request! C is a foundational language in computer science. Here is a comprehensive look at C, covering its history, importance, structure, and fundamental components.
📜 History of C
C is a general-purpose, procedural computer programming language developed in the early 1970s by Dennis Ritchie at Bell Labs.
 

  • Origin: It was primarily developed to write the UNIX operating system, which was previously written in assembly language.
  • Predecessors: C evolved from earlier languages:
    • ALGOL 60 (1960)
    • CPL (Combined Programming Language, 1963)
    • BCPL (Basic CPL, 1967)
    • B (developed by Ken Thompson, 1970)
  • Standardization: The language was later standardized by the American National Standards Institute (ANSI) in 1989, resulting in ANSI C or C89. This
...
Continue reading "Understanding the C Programming Language: History and Structure" »