Tuesday, August 23, 2022

94. Binary Tree Inorder Traversal

August 23, 2022

Here is the link. 

C# | Quick learner | using recursive function or stack

August 23, 2022

I like to write a working solution using recursive function, and review my last practice back in 2018.

Solution 1:
I choose to use C# List and also write a function to pass List as a function argument, so all nodes in the tree will be visited once and be added to List in inorder traversal order.

Space complexity: Using O(N) space, List
Time complexity: O(N), N is the total number of nodes in the tree

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _94_inorder_traversal
{
    class Program
    {
        public class TreeNode {
            public int val;
            public TreeNode left;
            public TreeNode right;
            public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
                this.val = val;
                this.left = left;
                this.right = right;
            }
        }

        static void Main(string[] args)
        {
            var root = new TreeNode(1);
            root.right = new TreeNode(2);
            root.right.left = new TreeNode(3);
            var list = InorderTraversal(root);
            Debug.Assert(string.Join(",", list).CompareTo("1,3,2") == 0); 
        }

        /// <summary>
        /// emtpy tree, with one root node, with more nodes
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public static IList<int> InorderTraversal(TreeNode root) 
        {
            var list = new List<int>();
            runInorderTraversal(root, list);

            return list;             
        }

        private static void runInorderTraversal(TreeNode root, IList<int> list)
        {
            if (root == null)
            {
                return;
            }

            runInorderTraversal(root.left, list);
            list.Add(root.val);
            runInorderTraversal(root.right, list);
        }
    }
}

Solution 2 | Using stack | iterative solution
I think that the design should be simple. Go over a few test cases, and then complete the design.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _94_inorder_traversal_iterative
{
    class Program
    {
        public class TreeNode
        {
            public int val;
            public TreeNode left;
            public TreeNode right;
            public TreeNode(int val = 0, TreeNode left = null, TreeNode right = null)
            {
                this.val = val;
                this.left = left;
                this.right = right;
            }
        }

        static void Main(string[] args)
        {
            var root = new TreeNode(1);
            root.right = new TreeNode(2);
            root.right.left = new TreeNode(3);
            var list = InorderTraversal(root);
            Debug.Assert(string.Join(",", list).CompareTo("1,3,2") == 0);
        }
       
        /// <summary>
        /// study code
        /// 
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public static IList<int> InorderTraversal(TreeNode root)
        {
            var list = new List<int>();

            if (root == null)
            {
                return list;
            }

            // stack - inorder - left, root, right
            var stack = new Stack<TreeNode>();
            var current = root;

            // stack 
            // design - visit left child and right child at least once
            // put left child first, before root node itself. 
            // stack.Push - only once - in coding writing
            // stack.Pop - only once - in coding writing
            // 
            while (stack.Count > 0 || current != null)
            {
                // Go over an example
                // Binary tree - Test case 1: 
                // root = new TreeNode(1);
                // root.left = new TreeNode(2);
                // root.left.left = new TreeNode(3);
                // nodes should be pushed into stack: push 1, push 2, push 3
                // Work on test case 1, and then add a right node into tree, work on test case 2 to cover all test cases. 
                while (current != null)
                {
                    stack.Push(current);
                    current = current.left;
                }

                // Pop()
                current = stack.Pop();
                list.Add(current.val);

                // Go to right
                current = current.right;
            }

            return list;
        }
    }
}

Solution 3:

Oct. 4, 2018
It is a medium level tree algorithm. I submitted the solution more than four months ago. I like to review the code before I start to work on other 20 medium level tree algorithms. It is also a good idea to share here.

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     public int val;
 *     public TreeNode left;
 *     public TreeNode right;
 *     public TreeNode(int x) { val = x; }
 * }
 */
public class Solution {
    public IList<int> InorderTraversal(TreeNode root) // emtpy tree, with one root node, with more nodes
        {
            if (root == null)
            {
                return new List<int>(); 
            }

            var left = InorderTraversal(root.left);
            left.Add(root.val);
            var right = InorderTraversal(root.right);

            // add right to left list <- code review on August 23, 2022, it is not a good practice. 
            if (right.Count > 0)
            {
                foreach (var item in right)
                {
                    left.Add(item);
                }
            }

            return left; 
    }
}

I think that it is better to avoid copying the list from right variable to left. It takes extra time and no need to do that.

SABRE

 Sabre Corporation SABR recently announced that it is integrating the New Distribution Capability (“NDC”) content from Avianca Group into its global marketplace tools.

Avianca Group includes Avianca Airlines, Avianca Costa Rica, Avianca Ecuador and TACA International Airlines. With the latest agreement between the two companies, Avianca Group has become the first Latin American air carrier to distribute its NDC offers through Sabre's marketplace.

With this integration, Sabre-connected travel agents worldwide will be able to manage, shop and book unique NDC contents offered by Qatar Airways through the former’s Sabre Red 360 point-of-sale tool, corporate online booking tool — GetThere — as well as Sabre's Offer and Order APIs (application programming interfaces).

The Colombia-based airline group is integrating its NDC contents into Sabre’s marketplace in two phases – the first phase was started on Aug 1, and the second phase is slated to begin on Aug 15, which will cover more than 50 countries.

Sabre Corporation price-consensus-chart | Sabre Corporation Quote

The recent collaboration reflects the reliability of SABR’s Beyond NDC Program and Global Distribution System (“GDS”) platform, which work like a marketplace connecting travel suppliers with buyers. This, in turn, is likely to aid the company in expanding its customer share in the Airlines Solutions segment.

The leading travel-related software and technology provider has a customer base spread over 160 nations globally. Sabre is one of the largest marketplaces in the world that manages approximately $260 billion worth of global travel spending annually. Currently, it has more than 425,000 agency partners globally.

Of late, Sabre has been showing signs of a turnaround with consecutive deal wins from major global airlines, hoteliers and travel agencies. In July this year, the company announced that it integrated the NDC content from Finnair and Qatar Airways into its GDS.

In June this year, the company announced that the Turkey-based online travel marketplace company, Wingie Enuygun, entered a multi-year renewal of the GDS agreement to accelerate its international growth plans.

In the same month, Sabre strengthened its existing relationship with Hong Kong’s Cathay Pacific Airways by inking a new distribution agreement. Per the deal, Cathay Pacific will be utilizing Sabre’s NDC-enabled consistent end-to-end workflow solution to distribute offerings to worldwide travel agencies through Sabre’s travel marketplace.

Monday, August 22, 2022

XAMPP - Local host - Wordpress

Tell Your Friends about XAMPP

 

Community

XAMPP has been around for more than 10 years – there is a huge community behind it. You can get involved by joining our Forums, liking us on Facebook, or following our exploits on Twitter.

https://www.apachefriends.org/download_success.html

How to Install WordPress on Localhost (6 Easy Steps)

Here is the link. 



How to Connect to Notepad++ FTP and How to Edit Server Files Using It

Here is the link.

If you’re a web developer or planning to be one, Notepad++ is an indispensable tool for your workflow. It provides a quicker way to modify code on your server than using an FTP client. As such, in this article, we’ll be showing you how to establish a Notepad++ FTP connection and get remote access to your server.

Computer reservation system

August 22, 2022

Here is the link. 

Computer reservation systems, or central reservation systems (CRS), are computerized systems used to store and retrieve information and conduct transactions related to air travel, hotels, car rental, or other activities. Originally designed and operated by airlines, CRSs were later extended for use by travel agencies, and global distribution systems (GDSs) to book and sell tickets for multiple airlines. Most airlines have outsourced their CRSs to GDS companies,[1] which also enable consumer access through Internet gateways. Modern GDSs typically also allow users to book hotel rooms, rental cars, airline tickets as well as other activities and tours. They also provide access to railway reservations and bus reservations in some markets, although these are not always integrated with the main system. These are also used to relay computerized information for users in the hotel industry, making reservation and ensuring that the hotel is not overbooked.

Airline reservations systems may be integrated into a larger passenger service system, which also includes an airline inventory system and a departure control system. The current centralised reservation systems are vulnerable to network-wide system disruptions.


Origins[edit]

In 1946, American Airlines installed the first automated booking system, the experimental electromechanical Reservisor. A newer machine with temporary storage based on a magnetic drum, the Magnetronic Reservisor, soon followed. This system proved successful, and was soon being used by several airlines, as well as Sheraton Hotels and Goodyear for inventory control. It was seriously hampered by the need for local human operators to do the actual lookups; ticketing agents would have to call a booking office, whose operators would direct a small team operating the Reservisor and then read the results over the telephone. There was no way for agents to directly query the system.[citation needed]

The MARS-1 train ticket reservation system was designed and planned in the 1950s by the Japanese National Railways' R&D Institute, now the Railway Technical Research Institute, with the system eventually being produced by Hitachi in 1958.[6] It was the world's first seat reservation system for trains.[7] The MARS-1 was capable of reserving seat positions, and was controlled by a transistor computer with a central processing unit and a 400,000-bit magnetic drum memory unit to hold seating files. It used many registers, to indicate whether seats in a train were vacant or reserved to accelerate searches of and updates to seat patterns, for communications with terminals, printing reservation notices, and CRT displays.[6]


Remote access[edit]

In 1953, Trans-Canada Airlines (TCA) started investigating a computer-based system with remote terminals, testing one design on the University of Toronto's Manchester Mark 1 machine that summer. Though successful, the researchers found that input and output was a major problem. Ferranti Canada became involved in the project and suggested a new system using punched cards and a transistorized computer in place of the unreliable tube-based Mark I. The resulting system, ReserVec, started operation in 1962, and took over all booking operations in January 1963. Terminals were placed in all of TCA's ticketing offices, allowing all queries and bookings to complete in about one second with no remote operators needed.

In 1953, American Airlines CEO C. R. Smith chanced to sit next to R. Blair Smith, a senior IBM sales representative, on a flight from Los Angeles to New York. C.R. invited Blair to visit their Reservisor system and look for ways that IBM could improve the system. Blair alerted Thomas Watson Jr. that American was interested in a major collaboration, and a series of low-level studies started. Their idea of an automated airline reservation system (ARS) resulted in a 1959 venture known as the Semi-Automatic Business Research Environment (SABRE), launched the following year.[8] By the time the network was completed in December 1964, it was the largest civil data processing system in the world.

Other airlines established their own systems. Pan Am launched its PANAMAC system in 1964. Delta Air Lines launched the Delta Automated Travel Account System (DATAS) in 1968. United Airlines and Trans World Airlines followed in 1971 with the Apollo Reservation System and Programmed Airline Reservation System (PARS), respectively. Soon, travel agents began pushing for a system that could automate their side of the process by accessing the various ARSes directly to make reservations. Fearful this would place too much power in the hands of agents, American Airlines executive Robert Crandall proposed creating an industry-wide computer reservation system to be a central clearing house for U.S. travel; other airlines demurred, citing fear of antitrust prosecution.


Travel agent access[edit]

In 1976, United Airlines began offering its Apollo system to travel agents; while it would not allow the agents to book tickets on United's competitors, the marketing value of the convenient terminal proved indispensable. SABRE, PARS, and DATAS were soon released to travel agents as well. Following airline deregulation in 1978, an efficient CRS proved particularly important; by some counts, Texas Air executive Frank Lorenzo purchased money-losing Eastern Air Lines specifically to gain control of its SystemOne CRS.

Also in 1976 Videcom international with British Airways, British Caledonian and CCL launched Travicom, the world's first multi-access reservations system (wholly based on Videcom technology), forming a network providing distribution for initially two and subsequently 49 subscribing international airlines (including British Airways, British Caledonian, Trans World Airlines, Pan Am, Qantas, Singapore Airlines, Air France, Lufthansa, SAS, Air Canada, KLM, Alitalia, Cathay Pacific and Japan Airlines) to thousands of travel agents in the UK. It allowed agents and airlines to communicate via a common distribution language and network, handling 97% of UK airline business trade bookings by 1987. The system went on to be replicated by Videcom in other areas of the world including the Middle East (DMARS), New Zealand, Kuwait (KMARS), Ireland, Caribbean, United States and Hong Kong. Travicom was a trading name for Travel Automation Services Ltd. When British Airways (who by then owned 100% of Travel Automation Services Ltd) chose to participate in the development of the Galileo system Travicom changed its trading name to Galileo UK and a migration process was put in place to move agencies from Travicom to Galileo.

European airlines also began to invest in the field in the 1980s initially by deploying their own reservation systems in their homeland, propelled by growth in demand for travel as well as technological advances which allowed GDSes to offer ever-increasing services and searching power. In 1987, a consortium led by Air France and West Germany's Lufthansa developed Amadeus, modeled on SystemOne. Amadeus Global Travel Distribution was launched in 1992. In 1990, Delta, Northwest Airlines, and Trans World Airlines formed Worldspan, and in 1993, another consortium (including British Airways, KLM, and United Airlines, among others) formed the competing company Galileo GDS based on Apollo. Numerous smaller companies such as KIU have also formed, aimed at niche markets not catered for by the four largest networks, including the low-cost carrier segment, and small and medium size domestic and regional airlines.


Trends[edit]

For many years, global distribution systems (GDSs) have had a dominant position in the travel industry. To bypass the GDSs, and avoid high GDS fees, airlines have started to sell flights directly through their websites.[9] Another way to bypass the GDSs is direct connection to travel agencies, such as that of American Airlines.[10]


SABRE 

  • Online Travel Agencies:
  • Schedules for 400 airlines
  • 380 airline industry customers, including 44 airlines representing all major alliances
  • 88,000 hotels
  • 50 rail carriers
  • 180 tour operators
  • 13 cruise lines
  • 24 car rental brands serving 30,000 locations
  • 9 limousine vendors providing access to more than 33,500 ground service providers
  • 55,000 travel agencies in over 100 countries


Travelport GDS Includes Apollo (1971), Galileo (1987) and Worldspan (1990)


Airline reservation systems (ARS)

 Airline reservation systems (ARS) are systems that allow an airline to sell their inventory (seats). It contains information on schedules and fares and contains a database of reservations (or passenger name records) and of tickets issued (if applicable). ARSs are part of passenger service systems (PSS), which are applications supporting the direct contact with the passenger.

ARS eventually evolved into the computer reservations system (CRS). A computer reservation system is used for the reservations of a particular airline and interfaces with a global distribution system (GDS) which supports travel agencies and other distribution channels in making reservations for most major airlines in a single system


Overview


Airline reservation systems incorporate airline schedules, fare tariffs, passenger reservations and ticket records. An airline's direct distribution works within their own reservation system, as well as pushing out information to the GDS. The second type of direct distribution channel are consumers who use the internet or mobile applications to make their own reservations. Travel agencies and other indirect distribution channels access the same GDS as those accessed by the airline reservation systems, and all messaging is transmitted by a standardized messaging system that functions on two types of messaging that transmit on SITA's high level network (HLN). These messaging types are called Type A [usually EDIFACT format] for real time interactive communication and Type B [TTY] for informational and booking type of messages. Message construction standards set by IATA and ICAO, are global, and apply to more than air transportation. Since airline reservation systems are business critical applications, and they are functionally quite complex, the operation of an in-house airline reservation system is relatively expensive.

Prior to deregulation, airlines owned their own reservation systems with travel agents subscribing to them. Today, the GDS are run by independent companies with airlines and travel agencies being major subscribers.

As of February 2009, there are only four major GDS providers in the market: Amadeus, Travelport (which operates the Apollo, Worldspan and Galileo systems), Sabre and Shares. There is one major Regional GDS, Abacus, serving the Asian market and a number of regional players serving single countries, including Travelsky (China), Infini and Axess (both Japan) and Topas (South Korea). Of these, Infini is hosted within the Sabre complex, Axess is in the process of moving into a partition within the Worldspan complex, and Topas agencies will be migrating into Amadeus.

Reservation systems may host "ticket-less" airlines and "hybrid" airlines that use e-ticketing in addition to ticket-less to accommodate code-shares and interlines.

In addition to these "standardized" GDS, some airlines have proprietary versions which they use to run their flight operations. A few examples are Delta's OSS and Deltamatic systems and EDS SHARES. SITA Reservations remains the largest neutral multi-host airline reservations system, with over 100 airlines currently managing inventory.


Inventory


In the airline industry, available seats are commonly referred to as inventory. The inventory of an airline is generally classified into service classes (e.g. economy, premium economy, business or first class) and any number of fare classes, to which different prices and booking conditions may apply. Fare classes are complicated and vary from airline to airline, often indicated by a one letter code. The meaning of these codes are not often known by the passenger, but conveys information to airline staff, for example they may indicate that a ticket was fully paid, or discounted or purchased through a loyalty scheme, etc. Some seats may not be available for open sale, but reserved for example for connecting flight or loyalty scheme passengers. Overbooking is also a common practice, and is an exception to inventory management principles. One of the core functions of inventory management is inventory control. Inventory control monitors how many seats are available in the different fare classes, and by opening and closing individual fare classes for sale.

A flight schedule management system forms the foundation of the inventory management system. Besides other functions, it is critical for ticket sales, crew member assignments, aircraft maintenance, airport coordination, and connections to partner airlines. The schedule system monitors what and when aircraft will be available on particular routes, and their internal configuration. Inventory data is imported and maintained from the schedule distribution system. Changes to aircraft availability would immediately impact the available seats of the fleet, as well as the seats which had been sold.

The price for each sold seat is determined by a combination of the fares and booking conditions stored in the Fare Quote System,. In most cases, inventory control has a real time interface to an airline’s yield management system to support a permanent optimization of the offered booking classes in response to changes in demand or pricing strategies of competitors.


Availability display and reservation (PNR)


Users access an airline’s inventory through an availability display. It contains all offered flights for a particular city-pair with their available seats in the different booking classes. This display contains flights which are operated by the airline itself as well as code share flights which are operated in co-operation with another airline. If the city pair is not one on which the airline offers service, it may display a connection using its own flights or display the flights of other airlines. The availability of seats of other airlines is updated through standard industry interfaces. Depending on the type of co-operation, it supports access to the last seat (last seat availability) in real-time. Reservations for individual passengers or groups are stored in a so-called passenger name record (PNR). Among other data, the PNR contains personal information such as name, contact information or special services requests (SSRs) e.g. for a vegetarian meal, as well as the flights (segments) and issued tickets. Some reservation systems also allow to store customer data in profiles to avoid data re-entry each time a new reservation is made for a known passenger. In addition, most systems have interfaces to CRM systems or customer loyalty applications (aka frequent traveler systems). Before a flight departs, the so-called passenger name list (PNL) is handed over to the departure control system that is used to check-in passengers and baggage. Reservation data such as the number of booked passengers and special service requests is also transferred to flight operations systems, crew management and catering systems. Once a flight has departed, the reservation system is updated with a list of the checked-in passengers (e.g. passengers who had a reservation but did not check in (no shows) and passengers who checked in, but did not have a reservation (go shows)). Finally, data needed for revenue accounting and reporting is handed over to administrative systems.


Fare quote and ticketing


The Fares data store contains fare tariffs, rule sets, routing maps, class of service tables, and some tax information that construct the price – "the fare". Rules like booking conditions (e.g. minimum stay, advance purchase, etc.) are tailored differently between different city pairs or zones, and assigned a class of service corresponding to its appropriate inventory bucket. Inventory control can also be manipulated manually through the availability feeds, dynamically controlling how many seats are offered for a particular price by opening and closing particular classes.

The compiled set of fare conditions is called a fare basis code. There are two systems set up for the interchange of fares data — ATPCO and SITA, plus some system to system direct connects. This system distributes the fare tariffs and rule sets to all GDSs and other subscribers. Every airline employs staff who code air fare rules in accordance with yield management intent. There are also revenue managers who watch fares as they are filed into the public tariffs and make competitive recommendations. Inventory control is typically manipulated from here, using availability feeds to open and close classes of service.

The role of the ticketing complex is to issue and store electronic ticket records and the very small number of paper tickets that are still issued. Miscellaneous charges order (MCO) is still a paper document; IATA has working groups defining the replacement document the electronic multipurpose document (EMD) as at 2010. The electronic ticket information is stored in a database containing the data that historically was printed on a paper ticket including items such as the ticket number, the fare and tax components of the ticket price or exchange rate information. In the past, airlines issued paper tickets; since 2008, IATA has been supporting a resolution to move to 100% electronic ticketing. So far, the industry has not been able to comply due to various technological and international limitations. The industry is at 98% electronic ticket issuance today, although electronic processing for MCOs was not available in time for the IATA mandate.